I would like to add a LayoutParam (FLAG_TURN_SCREEN_ON) to a view that I have defined via XML.
EDIT: This is a window flag WindowManager.LayoutParams.
Would I do this in the xml as well, or is there a way to add the params to the view before i call:
setContentView(R.layout.my_view);
UPDATE: Apparently this was not the easiest way to go about waking up the phone. Check the accepted answer about using the PowerManger to do it.
Try using
before you call your
setContentViewmethod.Alternatively, try using the
PowerManagerclass. Make sure you request the properWAKE_LOCKpermission in your manifest:Here is an example from the documentation: