以下是 OnstartCommand :
中的代码WindowManager mWindowManager = (WindowManager)getSystemService(WINDOW_SERVICE);
View mView = mInflater.inflate(R.layout.mylockscreenlayout, null);
final WindowManager.LayoutParams mLayoutParams = new WindowManager.LayoutParams(ViewGroup.LayoutParams.MATCH_PARENT,
ViewGroup.LayoutParams.MATCH_PARENT,WindowManager.LayoutParams.TYPE_SYSTEM_ERROR,WindowManager.LayoutParams.FLAG_SHOW_WHEN_LOCKED
| WindowManager.LayoutParams.FLAG_DISMISS_KEYGUARD
| WindowManager.LayoutParams.FLAG_TURN_SCREEN_ON
| WindowManager.LayoutParams.FLAG_KEEP_SCREEN_ON ,
PixelFormat.TRANSLUCENT);
mWindowManager.addView(mView, mLayoutParams);
并添加 Manifest
<uses-permission android:name="android.permission.SYSTEM_ALERT_WINDOW" />
<service android:name=".LockOverlayService"
android:enabled="true"
android:exported="false"
android:process=":overlayservice" />
通过覆盖移动设备的整个显示,我没有通过锁定屏幕获得整个屏幕的布局,通过这个顶部状态栏是可见的。任何人建议解决方案让我的活动全屏覆盖整个移动屏幕。
答案 0 :(得分:1)
为主视图添加系统可见性,然后将此mView添加到窗口管理器,如:
WindowManager mWindowManager = (WindowManager)getSystemService(WINDOW_SERVICE);
View mView = mInflater.inflate(R.layout.mylockscreenlayout, null);
final WindowManager.LayoutParams mLayoutParams = new WindowManager.LayoutParams(ViewGroup.LayoutParams.MATCH_PARENT,
ViewGroup.LayoutParams.MATCH_PARENT,WindowManager.LayoutParams.TYPE_SYSTEM_ERROR,WindowManager.LayoutParams.FLAG_SHOW_WHEN_LOCKED
| WindowManager.LayoutParams.FLAG_DISMISS_KEYGUARD
| WindowManager.LayoutParams.FLAG_TURN_SCREEN_ON
| WindowManager.LayoutParams.FLAG_KEEP_SCREEN_ON ,
PixelFormat.TRANSLUCENT);
mView.setSystemUiVisibility(
View.SYSTEM_UI_FLAG_LAYOUT_STABLE
| View.SYSTEM_UI_FLAG_FULLSCREEN
| View.SYSTEM_UI_FLAG_VISIBLE
| View.SYSTEM_UI_FLAG_LAYOUT_FULLSCREEN
);
mView.setVisibility(View.VISIBLE);
mWindowManager.addView(mView, mLayoutParams);
检查一下,让我知道它是否有效?