在我们的应用程序中,我们有一个自定义弹出窗口。它在2.2 - >上工作完美。 4.0.3没有故障。如果你在弹出窗口中的编辑文本中拼错ICS中的一个单词并单击它以让android尝试更正它,应用程序每次都会立即崩溃:
E/AndroidRuntime(13275): android.view.WindowManager$BadTokenException: Unable to add window -- token android.view.ViewRootImpl$W@42929b28 is not valid; is your activity running?
E/AndroidRuntime(13275): at android.view.ViewRootImpl.setView(ViewRootImpl.java:515)
E/AndroidRuntime(13275): at android.view.WindowManagerImpl.addView(WindowManagerImpl.java:279)
E/AndroidRuntime(13275): at android.view.WindowManagerImpl.addView(WindowManagerImpl.java:193)
E/AndroidRuntime(13275): at android.view.WindowManagerImpl$CompatModeWrapper.addView(WindowManagerImpl.java:118)
E/AndroidRuntime(13275): at android.view.Window$LocalWindowManager.addView(Window.java:537)
E/AndroidRuntime(13275): at android.widget.PopupWindow.invokePopup(PopupWindow.java:988)
E/AndroidRuntime(13275): at android.widget.PopupWindow.showAtLocation(PopupWindow.java:845)
E/AndroidRuntime(13275): at android.widget.PopupWindow.showAtLocation(PopupWindow.java:809)
E/AndroidRuntime(13275): at android.widget.TextView$PinnedPopupWindow.updatePosition(TextView.java:9517)
E/AndroidRuntime(13275): at android.widget.TextView$PinnedPopupWindow.show(TextView.java:9474)
E/AndroidRuntime(13275): at android.widget.TextView$SuggestionsPopupWindow.show(TextView.java:9718)
E/AndroidRuntime(13275): at android.widget.TextView.showSuggestions(TextView.java:10010)
E/AndroidRuntime(13275): at android.widget.TextView.onTouchEvent(TextView.java:8319)
E/AndroidRuntime(13275): at android.view.View.dispatchTouchEvent(View.java:5486)
E/AndroidRuntime(13275): at android.view.ViewGroup.dispatchTransformedTouchEvent(ViewGroup.java:1959)
E/AndroidRuntime(13275): at android.view.ViewGroup.dispatchTouchEvent(ViewGroup.java:1728)
E/AndroidRuntime(13275): at android.view.ViewGroup.dispatchTransformedTouchEvent(ViewGroup.java:1959)
E/AndroidRuntime(13275): at android.view.ViewGroup.dispatchTouchEvent(ViewGroup.java:1728)
E/AndroidRuntime(13275): at android.view.ViewGroup.dispatchTransformedTouchEvent(ViewGroup.java:1959)
E/AndroidRuntime(13275): at android.view.ViewGroup.dispatchTouchEvent(ViewGroup.java:1728)
E/AndroidRuntime(13275): at android.widget.PopupWindow$PopupViewContainer.dispatchTouchEvent(PopupWindow.java:1576)
E/AndroidRuntime(13275): at android.view.View.dispatchPointerEvent(View.java:5662)
E/AndroidRuntime(13275): at android.view.ViewRootImpl.deliverPointerEvent(ViewRootImpl.java:2863)
E/AndroidRuntime(13275): at android.view.ViewRootImpl.handleMessage(ViewRootImpl.java:2442)
E/AndroidRuntime(13275): at android.os.Handler.dispatchMessage(Handler.java:99)
E/AndroidRuntime(13275): at android.os.Looper.loop(Looper.java:137)
E/AndroidRuntime(13275): at android.app.ActivityThread.main(ActivityThread.java:4340)
E/AndroidRuntime(13275): at java.lang.reflect.Method.invokeNative(Native Method)
E/AndroidRuntime(13275): at java.lang.reflect.Method.invoke(Method.java:511)
E/AndroidRuntime(13275): at com.android.internal.os.ZygoteInit$MethodAndArgsCaller.run(ZygoteInit.java:784)
E/AndroidRuntime(13275): at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:551)
E/AndroidRuntime(13275): at dalvik.system.NativeStart.main(Native Method)
这是抛出异常的源文件:
以及总是导致它的那条线:
res = sWindowSession.add(mWindow, mSeq, mWindowAttributes, getHostVisibility(), mAttachInfo.mContentInsets,mInputChannel);
问题是sWindowSession是服务的接口,我找不到服务的实现? (http://130.75.2.12/source/xref/android/4.0.3/frameworks-base/core/java/android/view/IWindowSession.aidl)
有没有人有关于服务本身的信息或我们在这里获得例外的原因?