android - Correct method for setKeepScreenOn / FLAG_KEEP_SCREEN_ON -


I'm using method setcrynon (true) and how it is not able to know how to present it The activity (where content view is set) I have been able to work it by calling one of my buttons which is always present in the scene, but it seems wrong - and I believe that there is a way to get around it should be there. I tried to refer to the current focus like this:

  getCurrentFocus (). SetKeepScreenOn (true);   

But if he did not have a single pointer exception, maybe there was no current focus, can someone tell me how I can reference the visual class which I am working in. Am I Thanks :)

Try:

  getWindow () AddFlags (WindowManager.LayoutParams.FLAG_KEEP_SCREEN_ON);   

getWindow is the method set for the activities, and you will not need to search for see first.

Comments