I am making an application in which I have to execute the method at the time set by user. Is there any way to overcome this problem?
Asked
Active
Viewed 338 times
0
-
Does the method need to run if the app is exited before that time? – Ted Hopp Apr 27 '12 at 15:16
3 Answers
1
Define a PendingIntent that will execute the operation then setup Alarm to execute the PendingIntent: http://developer.android.com/reference/android/app/AlarmManager.html
slayton
- 20,123
- 10
- 60
- 89
1
Maybe this could help you: http://developer.android.com/reference/java/util/TimerTask.html
And others related:
1
The best way to implement this would be to create a Service in your application that invokes an AlarmManager. The AlarmManager is used to trigger an event set in the future and invoking it in a service enables you to run it even when your application is closed.
A very fine tutorial of the same can be found here. Although i would suggest you to go through the AlarmManager documentation first.
Anurag Ramdasan
- 4,189
- 4
- 31
- 53