问题
I am using viewflipper for fling gesture recognition everything works fine for 2.0 and prior but in 2.2 and 2.1 it throws exception as "java.lang.IllegalArgumentException: Receiver not registered: android.widget.ViewFlipper" below is full debug trace.
java.lang.IllegalArgumentException: Receiver not registered: android.widget.ViewFlipper$1@452f8398
09-19 11:33:06.825: ERROR/AndroidRuntime(393): at android.app.ActivityThread$PackageInfo.forgetReceiverDispatcher(ActivityThread.java:793)
09-19 11:33:06.825: ERROR/AndroidRuntime(393): at android.app.ContextImpl.unregisterReceiver(ContextImpl.java:814)
09-19 11:33:06.825: ERROR/AndroidRuntime(393): at android.content.ContextWrapper.unregisterReceiver(ContextWrapper.java:331)
09-19 11:33:06.825: ERROR/AndroidRuntime(393): at android.widget.ViewFlipper.onDetachedFromWindow(ViewFlipper.java:104)
09-19 11:33:06.825: ERROR/AndroidRuntime(393): at android.view.View.dispatchDetachedFromWindow(View.java:6033)
09-19 11:33:06.825: ERROR/AndroidRuntime(393): at android.view.ViewGroup.dispatchDetachedFromWindow(ViewGroup.java:1158)
09-19 11:33:06.825: ERROR/AndroidRuntime(393): at android.view.ViewGroup.dispatchDetachedFromWindow(ViewGroup.java:1156)
09-19 11:33:06.825: ERROR/AndroidRuntime(393): at android.view.ViewGroup.dispatchDetachedFromWindow(ViewGroup.java:1156)
09-19 11:33:06.825: ERROR/AndroidRuntime(393): at android.view.ViewGroup.dispatchDetachedFromWindow(ViewGroup.java:1156)
09-19 11:33:06.825: ERROR/AndroidRuntime(393): at android.view.ViewRoot.dispatchDetachedFromWindow(ViewRoot.java:1630)
09-19 11:33:06.825: ERROR/AndroidRuntime(393): at android.view.ViewRoot.doDie(ViewRoot.java:2671)
09-19 11:33:06.825: ERROR/AndroidRuntime(393): at android.view.ViewRoot.die(ViewRoot.java:2641)
09-19 11:33:06.825: ERROR/AndroidRuntime(393): at android.view.WindowManagerImpl.removeViewImmediate(WindowManagerImpl.java:218)
09-19 11:33:06.825: ERROR/AndroidRuntime(393): at android.view.Window$LocalWindowManager.removeViewImmediate(Window.java:436)
09-19 11:33:06.825: ERROR/AndroidRuntime(393): at android.app.ActivityThread.handleDestroyActivity(ActivityThread.java:3684)
09-19 11:33:06.825: ERROR/AndroidRuntime(393): at android.app.ActivityThread.handleRelaunchActivity(ActivityThread.java:3789)
09-19 11:33:06.825: ERROR/AndroidRuntime(393): at android.app.ActivityThread.access$2400(ActivityThread.java:125)
09-19 11:33:06.825: ERROR/AndroidRuntime(393): at android.app.ActivityThread$H.handleMessage(ActivityThread.java:2037)
09-19 11:33:06.825: ERROR/AndroidRuntime(393): at android.os.Handler.dispatchMessage(Handler.java:99)
09-19 11:33:06.825: ERROR/AndroidRuntime(393): at android.os.Looper.loop(Looper.java:123)
09-19 11:33:06.825: ERROR/AndroidRuntime(393): at android.app.ActivityThread.main(ActivityThread.java:4627)
09-19 11:33:06.825: ERROR/AndroidRuntime(393): at java.lang.reflect.Method.invokeNative(Native Method)
09-19 11:33:06.825: ERROR/AndroidRuntime(393): at java.lang.reflect.Method.invoke(Method.java:521)
09-19 11:33:06.825: ERROR/AndroidRuntime(393): at com.android.internal.os.ZygoteInit$MethodAndArgsCaller.run(ZygoteInit.java:868)
09-19 11:33:06.825: ERROR/AndroidRuntime(393): at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:626)
09-19 11:33:06.825: ERROR/AndroidRuntime(393): at dalvik.system.NativeStart.main(Native Method)
There is issue on Google related to this bug 6191.
And the solutions mentioned in there seems to work only if your are creating ViewFlipper through code but in my case i am using ViewFlipper in XML which is my layout file and so i cant use the solution mentioned for extending the ViewFlipper i tried using delay nothing seems to work.
I am stuck awfully with this any help will be really appreciated.
Below is my layout code.
<ViewFlipper xmlns:android="http://schemas.android.com/apk/res/android"
android:id="@+id/flipper"
android:layout_width="fill_parent"
android:layout_height="fill_parent">
<LinearLayout xmlns:android="http://schemas.android.com/apk/res/android" android:id="@+id/parentView" android:layout_width="fill_parent" android:layout_height="fill_parent" android:background="@color/listingBG">
<TextView
android:id="@+id/statusMessage"
android:layout_height="fill_parent"
android:layout_width="fill_parent"
style="@style/TextLabel.Normal" android:visibility="gone"
android:text="No result" android:padding="15dp" android:gravity="center_horizontal"/>
<ScrollView android:layout_width="fill_parent" android:layout_height="fill_parent" android:scrollbars="none" android:id="@+id/scrollView" >
<RelativeLayout android:id="@+id/parentItemView" android:layout_height="wrap_content" android:layout_width="fill_parent">
</RelativeLayout>
</ScrollView>
</LinearLayout>
</ViewFlipper>
回答1:
You can extend the ViewFlipper and use the full name of your new class (with package) in the xml layout file:
<com.yourpackage.FixedViewFlipper>
...
</com.yourpackage.FixedViewFlipper>
You can even create distinct xml files for 2.1 and 2.2 versions using a layout directory name like res/layout-v7
and res/layout-v8
.
回答2:
I had the same problem as described in this question.
After some searching I found this question which looks like to solved my this problem for me. Why does keyboard-slide crash my app?
来源:https://stackoverflow.com/questions/3744954/viewflipper-receiver-not-registered-error-while-orientation-change-in-2-1-and-2