I have application which have timers and if the timers are stopped the application will wont work I need to keep the application on all time even when the app is turn off (I know doesn't makes sense) and also to save the files if the phone is switched down.
Asked
Active
Viewed 83 times
2 Answers
1
I need to keep the application on all time even when the app is turn off
You can you Service. Its for the same purpose.
Save the files if the phone is switched down
You can receive an intent ACTION_SHUTDOWN in the broadcast receiver, when phone is about to switch off. Then you can do whatever you want to do there. See Is there any way to receive a notification when the user powers off the device? for details.
Hope this helps.

Community
- 1
- 1

Shobhit Puri
- 25,769
- 11
- 95
- 124
-
Ok and with Service if the player press the back button the app will be close and not runned in background right ? – Stefan Aug 19 '13 at 23:13
-
If you read the link hat I gave ( Service) it mentions `facility for the application to tell the system about something it wants to be doing in the background (even when the user is not directly interacting with the application).`. So Service runs in the background as well. – Shobhit Puri Aug 19 '13 at 23:15