I could do that, but most material on the net seems to prefer using a Service. I have yet to see a webpage that nicely details the performance implications of using an Alarm vs. a Service. Even a short list of pros/cons for each class would be useful to me to understand the philosophy behind them. Currently they seem like they do similar things.
http://www.androidenea.com/2009/09/starting-android-service-after-boot.html and http://androidcookbook.com/Recipe.seam;jsessionid=5424397F3130CE7769FF47DD67742911?recipeId=1662&recipeFrom=ViewTOC Chapter4. Inter/Intra-Application Communication<http://androidcookbook.com/ChapterView.seam;jsessionid=5BE755569DB714C4A1AE979DFF1D82E5?chapterId=3610&cid=77584> Contributed byAshwini Shahapurkar<http://androidcookbook.com/Profile.seam;jsessionid=5BE755569DB714C4A1AE979DFF1D82E5?personId=1330> 2011-05-24 11:33:24 (updated 2011-12-13 06:35:56) In Published Edition?Yes 2 Votes Problem You have a service in your app and you want it to start after the phone reboots. Solution You need to listen to intent for boot events and start the service when event occurs. Discussion Whenever the platform boot is completed, an intent with android.intent.action.BOOT_COMPLETED action is broadcasted. You need to register your application to receive this intent. For registering add this to your AndroidManifest.xml <receiver android:name="ServiceManager"> <intent-filter> <action android:name="android.intent.action.BOOT_COMPLETED" /> </intent-filter></receiver> So you will have *ServiceManager* as broadcast receiver to receive the intent for boot event. The ServiceManager class shall be as follows: public class ServiceManager extends BroadcastReceiver { Context mContext; private final String BOOT_ACTION = "android.intent.action.BOOT_COMPLETED"; @Override public void onReceive(Context context, Intent intent) { // All registered broadcasts are received by this mContext = context; String action = intent.getAction(); if (action.equalsIgnoreCase(BOOT_ACTION)) { //check for boot complete event & start your service startService(); } } private void startService() { //here, you will start your service Intent mServiceIntent = new Intent(); mServiceIntent.setAction("com.bootservice.test.DataService"); mContext.startService(mServiceIntent); } } Since we are starting the Service, it too must be mentioned in AndroidManifest: <service android:name=".LocationService"> <intent-filter> <action android:name="com.bootservice.test.DataService"/> </intent-filter></service> The Service class must of course extend Service; for more on this see the recipe Keeping a Service running while other apps are on display<http://androidcookbook.com/Recipe.seam?recipeId=844&title=Keeping%20a%20Service%20running%20while%20other%20apps%20are%20on%20display> . Both the XML *receiver* and *service* definitions must be inside the * application* element in AndroidManifest.xml. There is no requirement to have any Activity in this application at all, but it will probably be more user-friendly if you do. In one example we have used a *PreferenceActivity* implementation as the main (and only) Activity of an app whose service is started at Reboot. On Tue, Jan 31, 2012 at 9:57 PM, Kristopher Micinski <[email protected] > wrote: > Can you register your app to receive the on boot broadcast and then > start the alarm manager there? > -- You received this message because you are subscribed to the Google Groups "Android Developers" group. To post to this group, send email to [email protected] To unsubscribe from this group, send email to [email protected] For more options, visit this group at http://groups.google.com/group/android-developers?hl=en

