Error prompt: java.lang.illegalargumentexception: receiver not registered
As the name suggests, the receiver has not been registered. This is an error caused by canceling the unregistered receiver
When we use the receiver, we must ensure that the register and unregister appear in pairs
When encountering this kind of problem, you need to check the registered and de registered code in your own code to see if there is time to call unregister many times
Most of the time, I take it for granted that it will, but there may be unexpected exits in the program. For example, in my program, I register in oncreate and cancel the registration in finish. Theoretically, when I enter and exit, it should appear in pairs, but actually it reports an error! At the end of the analysis, tabactivity, groupactivity and other nested structures are used in the original layout. When exiting the current activity, the finish method is executed many times
Therefore, it is suggested that the process of receiver registration and de registration be put into onresume and onpause for two reasons
(1) These two processes are bound to occur in pairs, so the above errors can be avoided
(2) Generally, we use receiver to accept notification to change UI (except in special cases). When the activity (UI) interface is in the background, it is not necessary to accept notification to change UI
Example:
On adroid2.1 and adroid2.2 devices, if the viewflipper control is used in the activity, the following error message will occur when switching between horizontal and vertical screens
java.lang.IllegalArgumentException: Receiver not registered: android.widget. ViewFlipper$1@43dee3c0
This is because ondetachedfromwindow() is inexplicably called before onattachedtowindow(). It’s said that it’s a bug. I don’t know if it’s fixed on the latest 2.3.
The following is a very simple solution to rewrite the ondetachedfromwindow() method of viewflipper
@Override
protected void onDetachedFromWindow () {
try {
super.onDetachedFromWindow();
}
catch (IllegalArgumentExceptione) {
stopFlipping();
}
}
Similar Posts:
- [Solved] android.content.ActivityNotFoundException: Unable to find explicit activity class
- How to Solve Error: Unable to instantiate activity ComponentInfo
- Extraction process integration mode registration error, ogg-08221, OCI error ora-44004 invalid qualified SQL name
- Using fastcgi_ finish_ Request to achieve asynchronous processing and improve the response speed of the page
- [Solved] Docker forever in “Docker is starting..” at Windows task
- [Solved] The activity must be exported or contain an intent-filter
- How to Solve __autoload() does not execute error
- How to Solve MySQL-python Install Error:Python version 2.7 required, which was not found in the registry
- Android – Unable to add window — token null is not for an application [How to Solve]