Android 7.0版本中调用屏幕上方的弹出窗口

时间:2017-09-05 12:58:22

标签: android android-7.0-nougat

我必须在通话屏幕上显示警告窗口。在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;

1 个答案:

答案 0 :(得分:1)

对于非系统应用,

WindowManager.LayoutParams.TYPE_SYSTEM_OVERLAY在API级别26中已被弃用,对于面向Android 8.0的应用,已被no longer works as it used to弃用;请改用WindowManager.LayoutParams.TYPE_APPLICATION_OVERLAY