当某些事件发生时屏幕被锁定时,我会显示一个弹出屏幕。
@Override
public void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
getWindow().addFlags(WindowManager.LayoutParams.FLAG_KEEP_SCREEN_ON |
WindowManager.LayoutParams.FLAG_SHOW_WHEN_LOCKED |
WindowManager.LayoutParams.FLAG_TURN_SCREEN_ON);
}
问题是 - 在经历了很多挫折之后我发现了answer,说当activity
使用Theme.Dialog
时这不起作用。
我希望我的活动不全屏,它假设或多或少像短信弹出通知。如果没有Theme.Dialog
主题,我怎么能这样做?
答案 0 :(得分:0)
不确定这是否是您正在寻找的东西,但这会在窗口中弹出一切为我弹出:
代码的关键部分是'WRAP_CONTENT':
WindowManager mWindowManager = (WindowManager) getSystemService(WINDOW_SERVICE);
View mView = View.inflate(getApplicationContext(), R.layout.dialogue_page, null);
WindowManager.LayoutParams mLayoutParams = new WindowManager.LayoutParams(
ViewGroup.LayoutParams.WRAP_CONTENT,
ViewGroup.LayoutParams.WRAP_CONTENT, 0, 0,
WindowManager.LayoutParams.TYPE_SYSTEM_OVERLAY,
WindowManager.LayoutParams.FLAG_SHOW_WHEN_LOCKED
| WindowManager.LayoutParams.FLAG_DISMISS_KEYGUARD
| WindowManager.LayoutParams.FLAG_TURN_SCREEN_ON
| WindowManager.LayoutParams.FLAG_KEEP_SCREEN_ON,
PixelFormat.RGBA_8888);
mWindowManager.addView(mView, mLayoutParams);