Tag: CTI Manager flags application for OOP view RGBA logs RAS
Long before the test passed the code, now the phone upgraded Android7.0 after a run on the crash, reported such errors, the specific error is as follows:
Process:com.example.sho.android_anti_theft, pid:26807
Android.view. windowmanager$badtokenexception: Unable to add window-window [email protected] have already been added at Android.view.ViewRootImpl.setView (view rootimpl.java:691) at Android.view.WindowManagerGlobal.addView (windowmanagerglobal.java:342) at Android.view.WindowManagerImpl.addView (windowmanagerimpl.java:94) at Android.widget.toast$tn.handleshow ( toast.java:434) at Android.widget.toast$tn$2.handlemessage (toast.java:345) at Android.os.Handler.dispatchMessage ( handler.java:102) at Android.os.Looper.loop (looper.java:154) at Android.app.ActivityThread.main ( activitythread.java:6119) at Java.lang.reflect.Method.invoke (Native Method) at com.android.internal.os.zygoteinit$ Methodandargscaller.run (zygoteinit.java:886) at Com.android.internal.os.ZygoteInit.main (zygoteinit.java:776)
From the error message, I came to the conclusion that:
Before Android6.0, using WindowManager to add a suspended window, the type of suspension I used was type_toast, i.e.
Params.type = Windowmanager.layoutparams. Type_toast;
WindowManager. AddView (Contentview, params);
However, after the system upgrade Android7.0, it will be reported ndroid.view.windowmanager$badtokenexception:unable to add Window-window [e-mail protected] has Already been added
The mistake, specifically means that toast has been added to the window, so this time we can change the type_toast to Type_phone, so that you can display the suspended window, the program will not crash.
Here is the code for adding the suspended window, for reference only:
WindowManager WindowManager = (windowmanager) getsystemservice (Window_service); Windowmanager.layoutparams params = new windowmanager.layoutparams ();p Arams.type = Windowmanager.layoutparams.type_phone;params.format = pixelformat.rgba_8888;params.gravity = Gravity.LEFT | Gravity.top;params.flags = Windowmanager.layoutparams.flag_not_focusable;params.width = Windowmanager.getdefaultdisplay (). GetWidth ();p arams.height = Windowmanager.getdefaultdisplay (). GetHeight (); params.x = 0;params.y = 0;windowmanager.addview (Contentview, params); //Contentview need to define their own, and the addition of suspended windows need to dynamically apply for suspended window permissions.
Android Error: Windowmanager$badtokenexception:unable to add window – window has already been added