2

I am trying to show a pop-up on the lock-screen. And also after a interval of time the screen have to go to sleep. It is working with acquiring the wakelock and releasing it after a period of time on a Activity. But the problem is if the screen is touched when showing the popup, then the screen is not sleeping. Here is the code that i have used.

mPowerManager = (PowerManager) getSystemService(POWER_SERVICE);
wl = mPowerManager.newWakeLock(PowerManager.SCREEN_BRIGHT_WAKE_LOCK | PowerManager.ACQUIRE_CAUSES_WAKEUP, "tag");
wl.acquire();

And for releasing wakelock after a period .

new Handler().postDelayed(touchTimer, 1000 * 12);



    Runnable touchTimer = new Runnable() {

            @Override
            public void run() {     

                if(wl.isHeld())
                    wl.release();

            }
        };
J.R
  • 2,113
  • 19
  • 21

0 Answers0