0

I need to disable the lock screen and at the same time the black screen.. I need to do this in the onStart of my service.

with this disable the lock screen, this works well:

KeyguardManager keyguardManager = (KeyguardManager)getSystemService(Activity.KEYGUARD_SERVICE);
        KeyguardLock lock = keyguardManager.newKeyguardLock(KEYGUARD_SERVICE);
            lock.disableKeyguard();

how disable also the black screen? I tried this but do not work...

PowerManager pm2 = (PowerManager) context.getSystemService(Context.POWER_SERVICE);
       PowerManager.WakeLock wakel = pm2.newWakeLock(PowerManager.FULL_WAKE_LOCK, "AttvaSchermo");
       wakel.acquire();

or in the activity..

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

thanks in advance!

Tony
  • 163
  • 3
  • 13
  • See [here](http://stackoverflow.com/questions/2131948/force-screen-on/2134602#2134602) – Andrei Jun 17 '12 at 17:50
  • I already tried ... but the screen stays black – Tony Jun 17 '12 at 17:57
  • You will need a manifest permission to enable a wakelock, and do heed Hackbod's concerns mentioned in Andrei's link. FLAG_KEEP_SCREEN_ON is tied to the visibility of a UI so probably wouldn't apply to a service. – Chris Stratton Jun 17 '12 at 18:48

0 Answers0