Reputation: 85
I'm implementing my own alarm clock and want to take care about situations when it's time to alarm and display of my emulator is switched off.
I'm trying to handle it with the following code in onCreate() of my activity that pops up when it's time to alarm:
PowerManager pm = (PowerManager)mContext.getSystemService(
Context.POWER_SERVICE);
PowerManager.WakeLock wl = pm.newWakeLock(
PowerManager.SCREEN_DIM_WAKE_LOCK
| PowerManager.ON_AFTER_RELEASE,
TAG);
wl.acquire();
wl.release();
then I turn display off with a "switch-button" of my emulator. The music is playing but my display isn't waked up.
Also I tried to do it in this way:
getWindow().addFlags(WindowManager.LayoutParams.FLAG_KEEP_SCREEN_ON);
but the result was the same.
How can I handle this problem?
Upvotes: 0
Views: 573