Re : Re : [android-developers] Re: How to catch BOOT_COMPLETED_ACTION from an IntentReceiver
Okay for your information. I have used class for a this BroadcatReceiver : public class OnBootReceiverextends BroadcastReceiver { private static final String TAG="BootstrapService"; private BootstrapService mBootstrapService; @Override public void onReceive(Context context, Intent intent) { Log.d(TAG,"onReceive() ---ENTER---"); Log.d(TAG,"Intent ACTION: "+intent.getAction()); Log.d(TAG,"Intent CATEGORIES ..."); Set catSet=intent.getCategories(); Iterator it=catSet.iterator(); while (it.hasNext()) { Log.d(TAG," "+it.next()); } // WHILE Log.d(TAG,"Done."); // This is broadcast once, after the system has finished booting. if ( intent.getAction() == intent.ACTION_BOOT_COMPLETED ) { mBootstrapService.AutostartService(); } // IF Log.d(TAG,"onReceive() ---EXIT-"); } // onReceive } // OnBootReceiver And beside my second class that is launched by the previous one : import android.app.Service; //Need the following import to get access to the app resources, since this //class is in a sub-package. import com.OrangeLabs.BootstrapService.R; // @brief Main class for the BootstrapService Android service public class BootstrapService extends Service { ... --> Is it correct 'cos i don't see the log information in logcat through DDMS ? Furthermore i don't see my package running in the DDMS listing ? (For information, the test with the OnBootReceiver is well working and is well launched) And finaly my AndroidManifest.xml file : package="com.OrangeLabs.BootstrapService" android:versionCode="1" android:versionName="1.0"> ps : another interesting link was : http://groups.google.com/group/android-developers/browse_thread/thread/8a0ebc433e1351a3 Cordialement Thierry GAYET NextInnovation.org +33(0)663.849.589 ____ De : Mark Murphy À : android-developers@googlegroups.com Envoyé le : Mercredi, 24 Juin 2009, 15h02mn 52s Objet : Re: Re : [android-developers] Re: How to catch BOOT_COMPLETED_ACTION from an IntentReceiver GAYET Thierry wrote: > First thanks for your quick reply. I have well found the code you told > me about (OnBootReceiver). > > I have one more question 'cos i as i have said before i ma programming a > service that i want to start when Android boot. > > My core class extends Service not BroadcastReceiver. So may i extend > more than one time. I mean to extends Service and BroadcastReceiver. for > the same class ? > > Maybe i need to add a public class OnBootReceiver extends > BroadcastReceiver inside my service project ? But if so how to link this > second class with the service one ? BOOT_COMPLETED must be received by a element for a BroadcatReceiver. You have no choice in the matter. -- Mark Murphy (a Commons Guy) http://commonsware.com | http://twitter.com/commonsguy Android Development Wiki: http://wiki.andmob.org --~--~-~--~~~---~--~~ You received this message because you are subscribed to the Google Groups "Android Developers" group. To post to this group, send email to android-developers@googlegroups.com To unsubscribe from this group, send email to android-developers-unsubscr...@googlegroups.com For more options, visit this group at http://groups.google.com/group/android-developers?hl=en -~--~~~~--~~--~--~---
Re: Re : [android-developers] Re: How to catch BOOT_COMPLETED_ACTION from an IntentReceiver
GAYET Thierry wrote: > First thanks for your quick reply. I have well found the code you told > me about (OnBootReceiver). > > I have one more question 'cos i as i have said before i ma programming a > service that i want to start when Android boot. > > My core class extends Service not BroadcastReceiver. So may i extend > more than one time. I mean to extends Service and BroadcastReceiver. for > the same class ? > > Maybe i need to add a public class OnBootReceiver extends > BroadcastReceiver inside my service project ? But if so how to link this > second class with the service one ? BOOT_COMPLETED must be received by a element for a BroadcatReceiver. You have no choice in the matter. -- Mark Murphy (a Commons Guy) http://commonsware.com | http://twitter.com/commonsguy Android Development Wiki: http://wiki.andmob.org --~--~-~--~~~---~--~~ You received this message because you are subscribed to the Google Groups "Android Developers" group. To post to this group, send email to android-developers@googlegroups.com To unsubscribe from this group, send email to android-developers-unsubscr...@googlegroups.com For more options, visit this group at http://groups.google.com/group/android-developers?hl=en -~--~~~~--~~--~--~---
Re : [android-developers] Re: How to catch BOOT_COMPLETED_ACTION from an IntentReceiver
First thanks for your quick reply. I have well found the code you told me about (OnBootReceiver). I have one more question 'cos i as i have said before i ma programming a service that i want to start when Android boot. My core class extends Service not BroadcastReceiver. So may i extend more than one time. I mean to extends Service and BroadcastReceiver. for the same class ? Maybe i need to add a public class OnBootReceiver extends BroadcastReceiver inside my service project ? But if so how to link this second class with the service one ? Regards Thierry GAYET NextInnovation.org +33(0)663.849.589 De : Mark Murphy À : android-developers@googlegroups.com Envoyé le : Mercredi, 24 Juin 2009, 14h08mn 24s Objet : [android-developers] Re: How to catch BOOT_COMPLETED_ACTION from an IntentReceiver GAYET Thierry wrote: > Hi, because i need to start a background deamon not just when an > application need to bind with, i have searched a way to auto-start it. > One interesting reply was given in this maillist and i wanna more > explanation on the way to catch BOOT_COMPLETED_ACTION from an > IntentReceiver ? > > The previous thread that i have found on this maillist was this one: > > " Use an IntentReceiver and catch the BOOT_COMPLETED_ACTION. Then in the > IntentReceiver call Context.startService() (but use carefully, only when > you really need a background *service* to run all the time). " > > http://markmail.org/message/7r6afkcusvwe2wfz#query:android%20autostart%20service+page:1+mid:uee3n7yjip6nsmfr+state:results You'll see this covered as part of: http://androidguys.com/?p=4411 Sample code implementing BroadcastReceivers for BOOT_COMPLETED can be found at: http://commonsware.com/AdvAndroid/ (scroll down, download the "Source Code" from the link, and look for SysEvents/OnBoot and SysServices/Alarm projects) -- Mark Murphy (a Commons Guy) http://commonsware.com | http://twitter.com/commonsguy _The Busy Coder's Guide to *Advanced* Android Development_ Version 0.9 Available! --~--~-~--~~~---~--~~ You received this message because you are subscribed to the Google Groups "Android Developers" group. To post to this group, send email to android-developers@googlegroups.com To unsubscribe from this group, send email to android-developers-unsubscr...@googlegroups.com For more options, visit this group at http://groups.google.com/group/android-developers?hl=en -~--~~~~--~~--~--~---