I'm building an alarm app. I have it so a broadcastreceiver acquires a wakelock and starts the alarm activity. These are the flags I'm using:
Wakelock:
PowerManager pm = (PowerManager) ctx.getSystemService(Context.POWER_SERVICE);
WakeLock wakeLock = pm.newWakeLock(PowerManager.FULL_WAKE_LOCK |
PowerManager.ACQUIRE_CAUSES_WAKEUP |
PowerManager.ON_AFTER_RELEASE, ctx.getPackageName());
wakeLock.acquire();
Activity:
getWindow().addFlags(LayoutParams.FLAG_KEEP_SCREEN_ON +
LayoutParams.FLAG_DISMISS_KEYGUARD +
LayoutParams.FLAG_SHOW_WHEN_LOCKED +
LayoutParams.FLAG_TURN_SCREEN_ON);
What happens is that the activity gets called correctly, but then the lock screen gets called which fires the onPause on my activity. My activity then shows in front of the lock screen. So the overall behavior is the screen flickers on, then off, then back on. This causes my activity to go onCreate -> onResume -> onPause -> onResume. I would like to avoid the onPause if possible. Any suggestions?