public void Click(View view)
{
this.getWindow().clearFlags(WindowManager.LayoutParams.FLAG_KEEP_SCREEN_ON);
Handler handler = new Handler();
handler.postDelayed(new Runnable() {
public void run() {
开发者_开发技巧 this.getWindow().addFlags(WindowManager.LayoutParams.FLAG_TURN_SCREEN_ON);
}
}, 30000);
}
I want the screen to wake up after 30 sec (its set to 15 seconds timeout). But this doesnt work. What am i doing wrong? If theres a better way to do this, please provide a code sample, since im a newbie. THanks
You can try something similar to the following instead...
PowerManager pm = (PowerManager) getSystemService(Context.POWER_SERVICE);
PowerManager.WakeLock wl = pm.newWakeLock(PowerManager.SCREEN_DIM_WAKE_LOCK | ACQUIRE_CAUSES_WAKEUP | ON_AFTER_RELEASE, "My Tag");
wl.acquire();
..screen will stay on during this section..
wl.release();
See http://developer.android.com/reference/android/os/PowerManager.html for more info.
You might have to play around with the flags to get the effect you are looking for.
精彩评论