-1

I opened my application after I am not doing any kind of operation. I leave the mobile 5 min. After 5 min when I touch the my application it is showing black screen. Is there any way to avoid this idle state?

Sergey Glotov
  • 20,200
  • 11
  • 84
  • 98
Aswan
  • 5,085
  • 10
  • 46
  • 70

1 Answers1

2

This is easy to do. Use: getWindow().addFlags(WindowManager.LayoutParams.FLAG_KEEP_SCREEN_ON); in your onCreate method.

There is another way, called a WakeLock, but you really shouldn't use that unless you know what you're doing. See this post from one of the Android designers for more information about WakeLocks and why you shouldn't use them unless you're careful.

Community
  • 1
  • 1
Steve Haley
  • 55,374
  • 17
  • 77
  • 85