可以在屏幕的Activity加监听屏幕属性改变,发生改变则检查当前是否全屏状态。
是全屏状态发送,全屏的广播消息,到监听应用触发操作。
@Override
public void onWindowAttributesChanged(LayoutParams params) {
// TODO Auto-generated method stub
super.onWindowAttributesChanged(params);
Log.e(TAG,"onWindowAttributesChanged()"+getWindow().getAttributes().flags);
if (WindowManager.LayoutParams.FLAG_FULLSCREEN == getWindow().getAttributes().flags) {
Log.e(TAG,"onWindowAttributesChanged() FLAG_FULLSCREEN");
}
}
(注意该判断在屏幕切换横竖屏是也会触发,需要根据实际情况过滤横竖屏切换的情况。)
//设置全屏
getWindow().setFlags(WindowManager.LayoutParams.FLAG_FULLSCREEN, WindowManager.LayoutParams.FLAG_FULLSCREEN);
太复杂了。。。。