java.lang.IllegalArgumentException: Receiver not registered: android.widget.ViewFlipper$1@44b6ab90
It does not affect any devices before 2.1, and so what was troubling at first was that the 2.1 source code wasn't yet released so I could't diagnose the issue. Everyone knew it had to do with orientation changes on an Activity with a ViewFlipper, but why exactly it happens isn't clear (I took my own stab at it, but was incorrect about the exact cause; it just seems to happen randomly).
Thankfully, the source has been available now for a while. Obviously, the problem is that onDetachedFromWindow() is somehow being called before onAttachedToWindow(); but how do we come up with a workaround until it is fixed at Google?
One simple solution is to override onDetachedFromWindow() and catch the error from super:
@Override
protected void onDetachedFromWindow() {
try {
super.onDetachedFromWindow();
}
catch (IllegalArgumentException e) {
}
}
The only problem with this is that the error is thrown before calling updateRunning(). A simple workaround for this is to call stopFlipping(), as that will kick off updateRunning() without any negative side effects:
@Override
protected void onDetachedFromWindow() {
try {
super.onDetachedFromWindow();
}
catch (IllegalArgumentException e) {
stopFlipping();
}
}
You should only use this version of the class on Android 2.1 phones, as they are the only ones requiring the fix.
EDIT May 25, 2010: ViewFlipper bug still occurs in Android 2.2. I sure hope you didn't filter based on apiLevel == 7; better to use apiLevel >= 7.
I've just had this problem as my first bug report in the Market so finding your post has saved me a huge amount of time tracking this down. Thanks for posting this.
ReplyDeleteDaniel,
ReplyDeleteGreat to get your blog on this! I am getting this issue in logs from Google for my ap. I will try your solution. However I do not see the reason for applying your fix only if the api is 2.1 or higher. I do not see any negative effect in applying it since you are calling the parent's functions. So is it really necessary?
Thank you very much for this workaround!
ReplyDeleteThis comment has been removed by the author.
ReplyDeleteAwesome, just got this error and found this post expecting it to be my fault. Many thanks for the work around!
ReplyDeleteJust wanted to add my thanks as well. Same problem here of course. Android 2.2.
ReplyDeleteHope to see it fixed in the future.
I agree with all of them, thank you.
ReplyDeleteReally? Works?!
ReplyDeleteLet me check it!
Beautiful. Thanks!
ReplyDeleteYes, it reallly works.
ReplyDeleteThank you.
Fixed my annoying issue, thanks a ton.
ReplyDeleteThank you! I hope this will fix it... people are getting mad on the market!
ReplyDeleteIs this fixed in 2.3? Is there a bug report in the database?
ReplyDeleteStill happens in 2.3.4
ReplyDeletehttp://code.google.com/p/android/issues/detail?id=6191
ReplyDelete@Chris I hope you realize I was the one who started that bug. :)
ReplyDeleteI was incorrect in that it was not related to TabActivity, however.
Thank you a lot!! You made my day :D
ReplyDeleteThank you. You have saved my day :)
ReplyDeleteFantastic, thanks a lot!
ReplyDeleteThis comment has been removed by the author.
ReplyDeletei got this exception on android 4.2.1. ??
ReplyDeletecan you tell me why this happen .....
yes its error in api provider itself still it continues all levels
ReplyDelete