在 Android 7.0 版本的通话界面上方弹出 window
Popup window above call screen in Android 7.0 version
我必须在通话屏幕上显示警报 window。在 Android 7 以下此功能工作正常,但对于 Android 7 这不起作用。
在服务中正在创建一个 window 管理器并添加了视图,但是当设备在 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;
WindowManager.LayoutParams.TYPE_SYSTEM_OVERLAY
was deprecated in API Level 26 for non-system apps and no longer works as it used to for apps targeting Android 8.0; use WindowManager.LayoutParams.TYPE_APPLICATION_OVERLAY
代替。
我必须在通话屏幕上显示警报 window。在 Android 7 以下此功能工作正常,但对于 Android 7 这不起作用。
在服务中正在创建一个 window 管理器并添加了视图,但是当设备在 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;
WindowManager.LayoutParams.TYPE_SYSTEM_OVERLAY
was deprecated in API Level 26 for non-system apps and no longer works as it used to for apps targeting Android 8.0; use WindowManager.LayoutParams.TYPE_APPLICATION_OVERLAY
代替。