I got to know boot complete intent is not supported by android version 3.1 and above from here. But in my application. I want to start services automatically in my application after device is rebooted. I do not want user to start my application manually. How can I do it ? Thanks for help in advance.
Asked
Active
Viewed 2,422 times
3 Answers
0
What makes you think the ACTION_BOOT_COMPLETED broadcast is no longer sent? I make frequent use of it, and so do others. Just be sure you have RECEIVE_BOOT_COMPLETED permission in your manifest.

323go
- 14,143
- 6
- 33
- 41
-
Even it worked for me in gingerbread. But I am not getting this intent in Samsung galuxy s3, according to http://www.vogella.com/blog/2011/12/11/automatically-starting-services-in-android-after-booting/. What can I do. – thej Dec 07 '12 at 07:38
-
1All Lars is saying, is that as of HoneyComb, an app has to be started at least once before the BOOT_COMPLETED broadcast can be received. It still works. – 323go Dec 07 '12 at 07:47
-
Ya but I do not want user intervention to open activity and start the application. – thej Dec 07 '12 at 07:52
-
No way around that, I'm afraid... however, if the app is started once, the BOOT_COMPLETED broadcast will be received on all subsequent boots, and no further user-interaction be required. – 323go Dec 07 '12 at 07:56
-
@thej, i agree with 323go's comment.... App should strat once before it receives BOOT_COMPLETED.... I mean u should start the app once, than later on if u reboot the device it will work and open up your application – G M Ramesh Dec 07 '12 at 07:59
0
try the following steps to start the application after boot:
create a class which extends BroadcastReceiver:
public class AutostartService extends BroadcastReceiver {
@Override
public void onReceive(Context context, Intent intent) {
System.out.println("in broad....");
if ((intent.getAction() != null) && (intent.getAction().equals("android.intent.action.BOOT_COMPLETED")))
{
System.out.println("in broadcast receiver.....");
Intent i = new Intent(context, Splash.class);
i.setFlags(Intent.FLAG_ACTIVITY_NEW_TASK);
context.startActivity(i);
}
}
}
and also add this in android manifest file:
<uses-permission android:name="android.permission.RECEIVE_BOOT_COMPLETED"/>
<receiver android:name=".AutostartService" android:enabled="true"
android:exported="true">
<intent-filter>
<action android:name="android.intent.action.BOOT_COMPLETED" />
<category android:name="android.intent.category.DEFAULT" />
</intent-filter>
</receiver>

G M Ramesh
- 3,420
- 9
- 37
- 53
-
This works for me also but only in gingerbread. I don't receive this intent for the android version 3.1 and above( Samsung galuxy s3). What I can do for this. – thej Dec 07 '12 at 07:35
-
I think in some devices it wont work as i have also faced similar kind of problem with few samsung devices... the manufacturer will change the hardware according to there requirement so they might not have provide permission for this... it worked in all HTC devices but it worked only in few samsung devices – G M Ramesh Dec 07 '12 at 07:39
0
Well this is pretty old now and probably most people learned it but still might be useful.
From 3.1+ and on, in order to receive the BOOT_COMPLETED
, your app must be started at least once by the user.
NOTE: This rule doesn't apply to /system
apps

SarpSTA
- 279
- 2
- 15