I need to restart my android after a time. My application is a slideshow with images. The user close the application by home button or by back button. I need to restart the application after a time (a few minutes after the lost user's touch on the device - like the screen ssaver works). Is it possible to do this? Can anyone help me how can I do this?
Asked
Active
Viewed 464 times
2 Answers
0
I'm not sure it's a very good idea. If your user wants to quit your app, why should you bring it to the front?
However, I think you can achieve that using a background service, which launch an Intent after a certain time.

Aerilys
- 1,628
- 1
- 16
- 22
0
Imho the best solution is Alarm Manager. http://developer.android.com/reference/android/app/AlarmManager.html sample:
long nexttime = (new Date()).getTime() + 60L*60L*1000L;//one hour after.
AlarmManager am=(AlarmManager)getSystemService(Activity.ALARM_SERVICE);
Intent intent = new Intent(this, MyService.class);
intent.putExtra(SomeExtras, false);//for instance
PendingIntent pi = PendingIntent.getService(this, 12345, intent, PendingIntent.FLAG_CANCEL_CURRENT);
am.set(AlarmManager.RTC,nexttime, pi);

Vyacheslav
- 26,359
- 19
- 112
- 194