How to start my application when device boots?

make my application start when boot complete on/off

  • Heloo everyone im new to android development and im developing an android application for my graduation project my application must start when the device boot up so to that i put these lines in the AndroidManifest file <!--this to make app run at start up--> <receiver android:name="MyIntentReceiver"> <intent-filter> <action android:name="android.intent.action.BOOT_COMPLETED" /> <category android:name="android.intent.category.HOME" /> </intent-filter> </receiver> so my program run autmaticlly when boot complete. my question is how to stop this by user?? i want to put a toggle button on/off for this option so the user can chose if he want the app to start automaticlly in background or manually ??? thanks in advance

  • Answer:

    This sounds pretty straight forward. Basically, when the phone starts, the Receiver class "MyIntentReceiver" will run. Inside this receiver you can put code based on user preferences to either start the application or do nothing. The toggle would be a CheckBoxPreference in the user preferences. Let me know if you have any questions.

user935143 at Stack Overflow Visit the source

Was this solution helpful to you?

Other answers

so my program run automatically when boot complete. I would say no to that. It is rather you receiver gets notified when boot is completed. From that point on, your program has to decide to fire up your activity/service in onReceive() method of your receiver. Thus, you will need to save a preference to give option to user. When your receiver gets notified, check the pref setting set by user. For more information about saving preference, you can refer to http://developer.android.com/guide/topics/data/data-storage.html#pref

PH7

Related Q & A:

Just Added Q & A:

Find solution

For every problem there is a solution! Proved by Solucija.

  • Got an issue and looking for advice?

  • Ask Solucija to search every corner of the Web for help.

  • Get workable solutions and helpful tips in a moment.

Just ask Solucija about an issue you face and immediately get a list of ready solutions, answers and tips from other Internet users. We always provide the most suitable and complete answer to your question at the top, along with a few good alternatives below.