Max Kammerer
Max Kammerer

Reputation: 116

Screen off in android emulator

I tried to test my application in android emulator, but could not test it in case when the screen is go off (battery safe mode) but application is still alive (perform some computation), is there any flags for the emulator to emulate this behavior (screen off)?

Upvotes: 4

Views: 636

Answers (1)

Chirag Patel
Chirag Patel

Reputation: 1611

private Window wind;

wind = this.getWindow();
        wind.addFlags(LayoutParams.FLAG_DISMISS_KEYGUARD);
        wind.addFlags(LayoutParams.FLAG_SHOW_WHEN_LOCKED);
        wind.addFlags(LayoutParams.FLAG_TURN_SCREEN_OFF);

try this.

Upvotes: 2

Related Questions