3

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;
Bryan
  • 14,756
  • 10
  • 70
  • 125

1 Answers1

1

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.

Bryan
  • 14,756
  • 10
  • 70
  • 125
  • 2
    still not working. i am trying to develope a caller id like true caller but my caller id not showing when device is locked in android 7 . – Ankit Pawar Sep 05 '17 at 13:26