Reputation: 689
I'm trying to develop a very simple app that displays like a slideshow of images which Im sure ill be able to figure out (if anyone has any advice would be much appreciated) but what im wondering is there any way I can stop the device from going to sleep if its left cycling through these images?
Upvotes: 1
Views: 2577
Reputation: 3790
using
getWindow().addFlags(WindowManager.LayoutParams.FLAG_KEEP_SCREEN_ON);
will make the screen always on which will disable the lock. Remove it by using
getWindow().clearFlags(WindowManager.LayoutParams.FLAG_KEEP_SCREEN_ON);
Upvotes: 6
Reputation: 1006554
Add android:keepScreenOn="true"
to some widget in your activity's layout XML file. While the activity is in the foreground, the device will not fall asleep.
Upvotes: 4
Reputation: 4847
You would use a wake lock.
http://developer.android.com/reference/android/os/PowerManager.WakeLock.html
Upvotes: 2