我必须在通话屏幕上显示警告窗口。在Android 7下面,此功能运行正常,但对于Android 7,这不起作用。
在服务中创建一个窗口管理器并添加了视图,但是当Android 7的设备被锁定时,它没有显示在通话屏幕上。
mParams = new WindowManager.LayoutParams(
width - 20,
ViewGroup.LayoutParams.WRAP_CONTENT,
WindowManager.LayoutParams.TYPE_SYSTEM_ALERT |
WindowManager.LayoutParams.TYPE_SYSTEM_OVERLAY,
WindowManager.LayoutParams.FLAG_NOT_TOUCHABLE |
WindowManager.LayoutParams.FLAG_NOT_TOUCH_MODAL |
WindowManager.LayoutParams.FLAG_NOT_FOCUSABLE |
WindowManager.LayoutParams.FLAG_KEEP_SCREEN_ON |
WindowManager.LayoutParams.FLAG_DISMISS_KEYGUARD |
WindowManager.LayoutParams.FLAG_SHOW_WHEN_LOCKED |
WindowManager.LayoutParams.FLAG_TURN_SCREEN_ON |
WindowManager.LayoutParams.FLAG_LAYOUT_NO_LIMITS,
PixelFormat.TRANSPARENT);
mParams.gravity = Gravity.CENTER;
答案 0 :(得分:1)
WindowManager.LayoutParams.TYPE_SYSTEM_OVERLAY
在API级别26中已被弃用,对于面向Android 8.0的应用,已被no longer works as it used to弃用;请改用WindowManager.LayoutParams.TYPE_APPLICATION_OVERLAY
。