my apps background process stops on device rebooting. What to do to make it always running also after device booted. Because my notification did not show on device boot
Asked
Active
Viewed 146 times
4
-
user broadcast receiver to listen boot complete event & start your app on boot complete – Vishal Pawar Oct 16 '12 at 07:23
-
If you're not using `BroadcastReceiver` Then, simply use that. Have a look at [this](http://stackoverflow.com/a/6392009/940096) – Praveenkumar Oct 16 '12 at 07:24
2 Answers
0
You have to use BroadcastReceiver. and call your process inside this class. And in your manifest,
<receiver android:name=".BroadCastClass">
<intent-filter>
<action android:name="android.intent.action.BOOT_COMPLETED" />
</intent-filter>
</receiver>
And add uses permission.
<uses-permission android:name="android.permission.RECEIVE_BOOT_COMPLETED" />

Umesh Suryawanshi
- 934
- 1
- 7
- 21
0
Example code for manipulate your application onBoot
of your application -
public class OnBootReceiver extends BroadcastReceiver
{
@Override
public void onReceive(Context context, Intent intent) {
Log.d("OnBootReceiver", "Hi, Mom!");
}
}
Add the below permission for onBoot
service -
<uses-permission android:name="android.permission.RECEIVE_BOOT_COMPLETED" />
And, in your manifest file, you've to add the OnBootReceiver
class for register it like below -
<receiver android:name=".OnBootReceiver">
<intent-filter>
<action android:name="android.intent.action.BOOT_COMPLETED" />
</intent-filter>
</receiver>
A perfect example from Commonsware available on GitHub

Community
- 1
- 1

Praveenkumar
- 24,084
- 23
- 95
- 173