简体   繁体   中英

How to detect phone inactivity on Android

When my app starts, a splashscreen appears and after this there is a slideshow with images. When user touch a image from slideshow, the app is closed (it is not working in background, it is killed). After that I need to detect phone inactivity to restart this app after 60 seconds of inactivity. Is it possible to do this, to wakeup the app after 60 seconds of inactivity?

you could try to set up an AlarmManager when your app is destroyed, which after 60 seconds will launch your app again.

You may find more about AlarmManager here: http://developer.android.com/reference/android/app/AlarmManager.html and here for an example: http://justcallmebrian.com/?p=129

Hope this helps!

possible Use AlarmManager with BroadcastReciever . send broadcast after every minute from aLarmManager . restart app in onReceive

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM