我正在开发一个跟踪应用程序,我希望它在Boot完成时自动启动。我的申请工作正常几天。 8到9天后,它没有收到启动完成的广播。 Android Manifest如下 -
<manifest xmlns:android="http://schemas.android.com/apk/res/android"
package="com.test"
android:installLocation="internalOnly"
android:versionCode="21"
android:versionName="6.4.1" >
<uses-sdk android:minSdkVersion="9" />
<uses-permission android:name="android.permission.RECEIVE_BOOT_COMPLETED" />
<uses-permission android:name="android.permission.ACCESS_NETWORK_STATE" />
<uses-permission android:name="android.permission.ACCESS_FINE_LOCATION" />
<uses-permission android:name="android.permission.INTERNET" />/
<uses-permission android:name="android.permission.WRITE_EXTERNAL_STORAGE" />
<uses-permission android:name="android.permission.WAKE_LOCK" />
<uses-permission android:name="android.permission.WRITE_SETTINGS" />
<uses-permission android:name="android.permission.READ_PHONE_STATE" />
<uses-permission android:name="android.permission.READ_LOGS"/>
<application
android:enabled="true"
android:name=".TrackingApplication"
android:icon="@drawable/icon"
android:label="TrackingProcess" >
<activity
android:name=".TrackingProcess"
android:configChanges="keyboardHidden|orientation"
android:label="@string/app_name"
android:theme="@style/Theme.Transparent"
android:screenOrientation="portrait" >
<intent-filter>
<action android:name="android.intent.action.MAIN" />
<category android:name="android.intent.category.LAUNCHER" />
</intent-filter>
</activity>
<activity android:name=".NotificationDialog"
android:theme="@android:style/Theme.Dialog"/>
<service
android:name=".TrackingService"
android:enabled="true" />
<receiver
android:name=".BootUpReceiver"
android:enabled="true"
android:exported="true"
android:label="BootUpReceiver">
<intent-filter
android:priority="999">
<action android:name="android.intent.action.BOOT_COMPLETED" />
<action android:name="android.intent.action.QUICKBOOT_POWERON" />
<category android:name="android.intent.category.DEFAULT" />
</intent-filter>
</receiver>
</application>
BootUpReceiver onReceive是As -
@Override
public void onReceive(Context context, Intent intent) {
Intent i = new Intent(context, TrackingProcess.class);
i.addFlags(Intent.FLAG_ACTIVITY_NEW_TASK);
context.startActivity(i);
}
TrackingProccess如下 -
public class TrackingProcess extends Activity {
@Override
public void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
startService(new Intent(this, TrackingService.class));
}
}
任何帮助将不胜感激。