我正在使用覆盖权限在我的应用中显示某些信息。
它在 尝试使用API 26时,我收到一个错误,基本上是单击时出现“窗口类型2003的权限被拒绝” 错误是...... params = new WindowManager.LayoutParams(
WindowManager.LayoutParams.WRAP_CONTENT,
WindowManager.LayoutParams.WRAP_CONTENT,
WindowManager.LayoutParams.TYPE_APPLICATION_OVERLAY,
WindowManager.LayoutParams.FLAG_NOT_FOCUSABLE
| WindowManager.LayoutParams.FLAG_NOT_TOUCH_MODAL
| WindowManager.LayoutParams.FLAG_WATCH_OUTSIDE_TOUCH
| WindowManager.LayoutParams.FLAG_LAYOUT_NO_LIMITS,
PixelFormat.TRANSLUCENT);
params.gravity = Gravity.CENTER | Gravity.START;
params.x = 100;
params.y = 50;
windowManager = (WindowManager) getSystemService(WINDOW_SERVICE);
windowManager.addView(floatingView, params);
E/MessageQueue-JNI: android.view.WindowManager$BadTokenException: Unable to add window android.view.ViewRootImpl$W@2231e0c -- permission denied for window type 2003
at android.view.ViewRootImpl.setView(ViewRootImpl.java:982)
at android.view.WindowManagerGlobal.addView(WindowManagerGlobal.java:381)
at android.view.WindowManagerImpl.addView(WindowManagerImpl.java:100)
at android.app.Dialog.show(Dialog.java:420)
at com.absomech.floatingapp.FloatingViewService.myDialog(FloatingViewService.java:610)
at com.absomech.floatingapp.FloatingViewService.access$100(FloatingViewService.java:46)
at com.absomech.floatingapp.FloatingViewService$3.onTouch(FloatingViewService.java:188)
at android.view.View.dispatchTouchEvent(View.java:12536)
at android.view.ViewGroup.dispatchTransformedTouchEvent(ViewGroup.java:3153)
at android.view.ViewGroup.dispatchTouchEvent(ViewGroup.java:2829)
at android.view.ViewGroup.dispatchTransformedTouchEvent(ViewGroup.java:3159)
at android.view.ViewGroup.dispatchTouchEvent(ViewGroup.java:2844)
at android.view.View.dispatchPointerEvent(View.java:12788)
at android.view.ViewRootImpl$ViewPostImeInputStage.processPointerEvent(ViewRootImpl.java:5670)
at android.view.ViewRootImpl$ViewPostImeInputStage.onProcess(ViewRootImpl.java:5465)
at android.view.ViewRootImpl$InputStage.deliver(ViewRootImpl.java:4958)
at android.view.ViewRootImpl$InputStage.onDeliverToNext(ViewRootImpl.java:5011)
at android.view.ViewRootImpl$InputStage.forward(ViewRootImpl.java:4977)
at android.view.ViewRootImpl$AsyncInputStage.forward(ViewRootImpl.java:5114)
at android.view.ViewRootImpl$InputStage.apply(ViewRootImpl.java:4985)
at android.view.ViewRootImpl$AsyncInputStage.apply(ViewRootImpl.java:5171)
at android.view.ViewRootImpl$InputStage.deliver(ViewRootImpl.java:4958)
at android.view.ViewRootImpl$InputStage.onDeliverToNext(ViewRootImpl.java:5011)
at android.view.ViewRootImpl$InputStage.forward(ViewRootImpl.java:4977)
at android.view.ViewRootImpl$InputStage.apply(ViewRootImpl.java:4985)
at android.view.ViewRootImpl$InputStage.deliver(ViewRootImpl.java:4958)
at android.view.ViewRootImpl.deliverInputEvent(ViewRootImpl.java:7736)
at android.view.ViewRootImpl.doProcessInputEvents(ViewRootImpl.java:7676)
at android.view.ViewRootImpl.enqueueInputEvent(ViewRootImpl.java:7637)
at android.view.ViewRootImpl$WindowInputEventReceiver.onInputEvent(ViewRootImpl.java:7847)
at android.view.InputEventReceiver.dispatchInputEvent(InputEventReceiver.java:197)
at android.os.MessageQueue.nativePollOnce(Native Method)
at android.os.MessageQueue.next(MessageQueue.java:325)
at android.os.Looper.loop(Looper.java:142)
at android.app.ActivityThread.main(ActivityThread.java:6944)
at java.lang.reflect.Method.invoke(Native Method)
at com.android.internal.os.Zygote$MethodAndArgsCaller.run(Zygote.java:327)
at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:1374)