Whenever I try to open my activity on the lock screen through a pending intent, it automatically closes itself before appearing. Its onCreate()
, onStart()
, onResume()
methods are called, but then suddenly onStop()
is called automatically. I have set all the required flags to wake up my device and turn the screen on in onResume()
method. This issue is only with the lock screen. Any suggestions?
This is my onResume
method:
@Override
protected void onResume() {
super.onResume();
Log.i("CallScreen", "onResume()");
this.getWindow().setFlags(
WindowManager.LayoutParams.FLAG_SHOW_WHEN_LOCKED|
WindowManager.LayoutParams.FLAG_FULLSCREEN|
WindowManager.LayoutParams.FLAG_TURN_SCREEN_ON|
WindowManager.LayoutParams.FLAG_KEEP_SCREEN_ON,
WindowManager.LayoutParams.FLAG_SHOW_WHEN_LOCKED|
WindowManager.LayoutParams.FLAG_FULLSCREEN|
WindowManager.LayoutParams.FLAG_TURN_SCREEN_ON|
WindowManager.LayoutParams.FLAG_KEEP_SCREEN_ON);
handler = new Handler();
r = new Runnable() {
@Override
public void run() {
Log.i("CallScreen", "run()");
startTimer();
playSound(CallScreen.this, getAlarmUri());
}
};
handler.postDelayed(r, 1000);
}