How can I have a timer fire a method to wake up the screen of an Android device?
I inserted this:
final Window win = getWindow();
win.addFlags(WindowManager.LayoutParams.FLAG_SHOW_WHEN_LOCKED
| WindowManager.LayoutParams.FLAG_DISMISS_KEYGUARD);
win.addFlags(WindowManager.LayoutParams.FLAG_KEEP_SCREEN_ON
| WindowManager.LayoutParams.FLAG_TURN_SCREEN_ON);
into the
@Override
protected void onCreate(Bundle savedInstanceState) {
method.
Additionally, I made a timer after a user clicks a button which runs the following program:
final int interval = 3000; // 3 Seconds
Handler handler = new Handler();
Runnable runnable = new Runnable(){
public void run() {
Toast.makeText(getApplicationContext(), "Here", Toast.LENGTH_SHORT).show();
}
};
handler.postAtTime(runnable, System.currentTimeMillis()+interval);
handler.postDelayed(runnable, interval);
I want to be able to click the power button of my Android device to sleep it within the 3 second interval and have it wake up after the run() gets fired. What do I call to trigger the screen to turn on?