Skip to content

Commit

Permalink
fix bugs on android5.0
Browse files Browse the repository at this point in the history
  • Loading branch information
seek4 committed Feb 24, 2016
1 parent ae016f5 commit c7b7c6d
Show file tree
Hide file tree
Showing 27 changed files with 1,210 additions and 52 deletions.
38 changes: 20 additions & 18 deletions AppControl/AndroidManifest.xml
Original file line number Diff line number Diff line change
@@ -1,37 +1,39 @@
<?xml version="1.0" encoding="utf-8"?>
<manifest xmlns:android="http://schemas.android.com/apk/res/android"
package="com.changhong.appcontrol"
android:sharedUserId="android.uid.system"
android:versionCode="1"
android:versionName="1.0" >

<uses-permission android:name="android.permission.RECEIVE_BOOT_COMPLETED"/>
<uses-permission android:name="android.permission.INTERNET"/>

<uses-sdk
android:minSdkVersion="8"
android:minSdkVersion="15"
android:targetSdkVersion="21" />

<uses-permission android:name="android.permission.INTERNET" />
<uses-permission android:name="android.permission.WRITE_EXTERNAL_STORAGE" />
<uses-permission android:name="android.permission.MOUNT_UNMOUNT_FILESYSTEMS" />
<uses-permission android:name="android.permission.RECEIVE_BOOT_COMPLETED" />

<application
android:allowBackup="true"
android:icon="@drawable/ic_launcher"
android:label="@string/app_name"
android:theme="@style/AppTheme" >
<activity
android:name=".MainActivity"
android:label="@string/app_name" >

<receiver android:name=".ControlReceiver" >
<intent-filter>
<action android:name="android.intent.action.MAIN" />
<category android:name="android.intent.category.LAUNCHER" />
</intent-filter>
</activity>

<receiver
android:name=".TransferReceiver">
<intent-filter >
<action android:name="android.intent.action.BOOT_COMPLETED"/>
<action android:name="com.changhong.appcontrol.transfer"/>
<action android:name="android.intent.action.BOOT_COMPLETED" />
<action android:name="com.changhong.action.appcontrol" />
</intent-filter>
</receiver>

<service
android:name=".ControlService"
android:exported="false" >
<intent-filter>
<action android:name="com.changhong.service.appcontrol" />
</intent-filter>
</service>
</application>

</manifest>
</manifest>
1 change: 0 additions & 1 deletion AppControl/project.properties
Original file line number Diff line number Diff line change
Expand Up @@ -12,4 +12,3 @@

# Project target.
target=android-19
android.library.reference.1=../appcompat_v7
11 changes: 5 additions & 6 deletions AppControl/res/layout/activity_main.xml
Original file line number Diff line number Diff line change
Expand Up @@ -6,19 +6,18 @@
android:paddingLeft="@dimen/activity_horizontal_margin"
android:paddingRight="@dimen/activity_horizontal_margin"
android:paddingTop="@dimen/activity_vertical_margin"
tools:context="com.changhong.appcontrol.MainActivity" >
tools:context="com.example.test.MainActivity" >

<TextView
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:text="@string/hello_world" />

android:text="囧甄环" />
<Button
android:id="@+id/button_send"
android:id="@+id/btn_test"
android:layout_centerInParent="true"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:text="发送广播"
android:layout_centerInParent="true"
android:text="TEST"
/>

</RelativeLayout>
5 changes: 2 additions & 3 deletions AppControl/res/menu/main.xml
Original file line number Diff line number Diff line change
@@ -1,12 +1,11 @@
<menu xmlns:android="http://schemas.android.com/apk/res/android"
xmlns:app="http://schemas.android.com/apk/res-auto"
xmlns:tools="http://schemas.android.com/tools"
tools:context="com.changhong.appcontrol.MainActivity" >

<item
android:id="@+id/action_settings"
android:orderInCategory="100"
android:title="@string/action_settings"
app:showAsAction="never"/>
android:showAsAction="never"
android:title="@string/action_settings"/>

</menu>
2 changes: 1 addition & 1 deletion AppControl/res/values-v11/styles.xml
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@
Base application theme for API 11+. This theme completely replaces
AppBaseTheme from res/values/styles.xml on API 11+ devices.
-->
<style name="AppBaseTheme" parent="Theme.AppCompat.Light">
<style name="AppBaseTheme" parent="android:Theme.Holo.Light">
<!-- API 11 theme customizations can go here. -->
</style>

Expand Down
2 changes: 1 addition & 1 deletion AppControl/res/values-v14/styles.xml
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@
AppBaseTheme from BOTH res/values/styles.xml and
res/values-v11/styles.xml on API 14+ devices.
-->
<style name="AppBaseTheme" parent="Theme.AppCompat.Light.DarkActionBar">
<style name="AppBaseTheme" parent="android:Theme.Holo.Light.DarkActionBar">
<!-- API 14 theme customizations can go here. -->
</style>

Expand Down
2 changes: 1 addition & 1 deletion AppControl/res/values/styles.xml
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@
Base application theme, dependent on API level. This theme is replaced
by AppBaseTheme from res/values-vXX/styles.xml on newer devices.
-->
<style name="AppBaseTheme" parent="Theme.AppCompat.Light">
<style name="AppBaseTheme" parent="android:Theme.Light">
<!--
Theme customizations available in newer API levels can go in
res/values-vXX/styles.xml, while customizations related to
Expand Down
59 changes: 59 additions & 0 deletions AppControl/src/com/changhong/appcontrol/ControlReceiver.java
Original file line number Diff line number Diff line change
@@ -0,0 +1,59 @@
package com.changhong.appcontrol;

import com.changhong.appcontrol.transfer.InfoTransfer;
import com.changhong.appcontrol.transfer.TransferCallBack;
import com.changhong.appcontrol.transfer.TransferUtils;

import android.content.BroadcastReceiver;
import android.content.Context;
import android.content.Intent;
import android.util.Log;
/**
* AppControl入口
* @author yangtong
*
*/
public class ControlReceiver extends BroadcastReceiver implements TransferCallBack{

public static final String TAG = "yangtong";
//public static final String SERVER_IP = "http://192.168.10.107";
public static final String SERVER_IP = "http://192.168.103.211";
//public static final String INFO_URL = "http://yangtong.me/control.json";

private Context context;

InfoTransfer transfer;
@Override
public void onReceive(Context context, Intent intent) {
Log.i(TAG, "ControlReceiver onReceive");
this.context = context;
if(!TransferUtils.isNetworkAvaiable(context)){// 无网络时2分钟后再次获取
TransferUtils.requestAgain(context, TransferUtils.REQUEST_DELAY);
return;
}
transfer = new InfoTransfer();
transfer.GetControlInfo(SERVER_IP+"/control.json", this);
}



/**
* 从服务器获取json数据结束后触发
*/
@Override
public void transferFinish(String controlJson) {
// 判断有效性,如果有效,则StartService进行处理
Log.i(TAG,"controlInfo >>"+controlJson);
if(transfer.isInfoEffective(controlJson)){
// 开Service继续接下来的操作
Intent intent = new Intent(context,ControlService.class);
intent.setAction("com.changhong.service.appcontrol");
intent.putExtra("info", controlJson);
context.startService(intent);
}else {
// 过一段时间后重新请求数据
TransferUtils.requestAgain(context, TransferUtils.REQUEST_DELAY);
}
}

}
Loading

0 comments on commit c7b7c6d

Please sign in to comment.