Dmitry
Dmitry

Reputation: 85

Switch on the screen of emulator

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

Answers (1)

TheCodeArtist
TheCodeArtist

Reputation: 22497

Use the ACQUIRE_CAUSES_WAKEUP flag to turn-ON the screen.

Upvotes: 1

Related Questions