Add android:keepScreenOn="true"
to some widget in your layout XML resource for this activity. So long as that widget is visible on the screen, the screen will not turn off automatically.
EDIT:
A WakeLock
, as suggested by other answers, technically will work. But then you have to manually release the WakeLock
(if you mess that up, the screen will stay on a long time). And, since you could mess it up, you need the WAKE_LOCK
permission. Using keepScreenOn
avoids all of that.