Reputation: 43
I have to show an alert window over a call screen. Below Android 7 this functionality is working fine, but for Android 7 this is not working.
In a service am creating a window manager and added the view in but when the device is locked in the case of Android 7 it's not showing over call screen.
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;
Upvotes: 3
Views: 1664
Reputation: 15155
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
instead.
Upvotes: 1