每当我尝试通过挂起的意图在锁定屏幕上打开我的活动时,它会在出现之前自动关闭。调用其onCreate()
,onStart()
,onResume()
方法,但随后会自动调用onStop()
。我已设置所有必需的标志来唤醒我的设备并在onResume()
方法中打开屏幕。此问题仅适用于锁定屏幕。有什么建议吗?
这是我的onResume
方法:
@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);
}