Android Question B4A - Force screen on?

Discussion in 'Android Questions' started by PhilipK, Apr 21, 2015.

  1. PhilipK

    PhilipK Member Licensed User

    I've trawled a lot and can't find how to programatically turn on the screen when it is off.

    The phone wake states appear to stop the screen going off when it's on but not be able to turn the screen on when it is off.

    The Toggle library has toggle.useractivity which might work but I'm unclear on how to set the 'when' variable.:

    upload_2015-4-21_12-38-41.png

    Many thanks in advance.
     
  2. Erel

    Erel Administrator Staff Member Licensed User

    PhoneWakeState.KeepAlive should turn on the screen. Make sure to call it from a service.
     
    peacemaker likes this.
  3. PhilipK

    PhilipK Member Licensed User

    It works, thanks Erel.

    PhoneWakeState.KeepAlive does light up the screen when called from a service. Not forgetting to ReleaseKeepAlive later.
     
    peacemaker likes this.
Loading...
  1. This site uses cookies to help personalise content, tailor your experience and to keep you logged in if you register.
    By continuing to use this site, you are consenting to our use of cookies.
    Dismiss Notice