I have a BootUpReceiver
class which I'm attempting to use with RECEIVE_BOOT_COMPLETED
to launch an Activity when the device boots. The problem is - it does not seem to do so when I launch the app then restart the device.
I have verified there is no issue running Activity1.java - the issue lies either in the Manifest or the BootUpReceiver
class but I'm not sure exactly why it will not launch after rebooting.
BootUpReceiver.java:
public class BootUpReceiver extends BroadcastReceiver{
@Override
public void onReceive(Context context, Intent intent) {
Intent i = new Intent(context, Activity1.class);
i.addFlags(Intent.FLAG_ACTIVITY_NEW_TASK);
context.startActivity(i);
}
}
<?xml version="1.0" encoding="utf-8"?>
<manifest xmlns:android="http://schemas.android.com/apk/res/android"
package="com.example.com.idg.voiscphone"
android:versionCode="1"
android:versionName="1.0" >
<uses-sdk
android:minSdkVersion="8"
android:targetSdkVersion="18" />
<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="com.idg.voiscphone.Activity1"
android:label="@string/app_name" >
<intent-filter>
<action android:name="android.intent.action.MAIN" />
<category android:name="android.intent.category.LAUNCHER" />
</intent-filter>
</activity>
<activity
android:name="com.idg.voiscphone.Activity2"
android:label="@string/app_name" >
</activity>
<activity
android:name="com.idg.voiscphone.Activity3"
android:label="@string/app_name" >
</activity>
<activity
android:name="com.idg.voiscphone.Activity3a"
android:label="@string/app_name" >
</activity>
<activity
android:name="com.idg.voiscphone.Activity3b"
android:label="@string/app_name" >
</activity>
<receiver android:enabled="true" android:name=".BootUpReceiver"
android:permission="android.permission.RECEIVE_BOOT_COMPLETED">
<intent-filter>
<action android:name="android.intent.action.BOOT_COMPLETED" />
<category android:name="android.intent.category.DEFAULT" />
</intent-filter>
</receiver>
</application>
</manifest>
Example Source:
http://androidrocksonmobility.blogspot.com/2012/01/how-to-create-auto-start-android.html