I want to schedule a service to run every minute and check if my app is still running. (I want to reopen the application if it is closed). Also, I still want this service to run every minute if my application was force killed by task manager. Thanks!
相关问题
- How can I create this custom Bottom Navigation on
- Bottom Navigation View gets Shrink Down
- How to make that the snackbar action button be sho
- Listening to outgoing sms not working android
- How to create Circular view on android wear?
This is not possible as of Android 3.1. If the user goes into Settings and force=stops your app, nothing of your app will run again, until the user manually launches one of your components.
If your process is terminated for other reasons (e.g., ordinary task-killer app from the Play Store, swiping your task away from the Recent Tasks list), your alarms scheduled with
AlarmManager
should remain intact, per Lucifer's suggestion.Any child sufficiently intelligent to use a phone will be sufficiently intelligent to reboot their device in safe mode and get rid of your app.
Use
AlarmManager
class, it works even if your device is in sleep mode.AlarmManager consumes lesser battery power than TimerTask or Thread. It works like painless AsyncTask.