ActivityThread exception in Android?
I am working on the task to search a location which stored in DB. After that i have to drop a pin on the corresponding location. I made a modification on Quick Search Box(QSB) to search the DB which is in my app. for that QSB performance i followed the Search Dictionary example in API Demos. when i click the search suggestion it reloads the current activity and drop the pin on it. when click the back button it shows the below exception in the Logcat. why it happens. Any Idea?
My Log CAT Value:
05-17 15:16:30.572: ERROR/ActivityThread(17448): Activity com.example.brown.Bru_Maps has leaked IntentReceiver android.net.NetworkConnectivityListener$ConnectivityBroadcastReceiver@432e6360 that was originally registered here. Are you missing a call to unregisterReceiver()?
05-17 15:16:30.572: ERROR/ActivityThread(17448): android.app.IntentReceiverLeaked: Activity com.example.brown.Bru_Maps has leaked IntentReceiver android.net.NetworkConnectivityListener$ConnectivityBroadcastReceiver@432e6360 that was originally registered here. Are you missing a call to unregisterReceiver()?
05-17 15:16:30.572: ERROR/ActivityThread(17448): at android.app.ActivityThread$PackageInfo$ReceiverDispatcher.<init>(ActivityThread.java:748)
05-17 15:16:30.572: ERROR/ActivityThread(17448): at android.app.ActivityThread$PackageInfo.getReceiverDispatcher(ActivityThread.java:576)
05-17 15:16:30.572: ERROR/ActivityThread(17448): at android.app.ApplicationContext.registerReceiverInternal(ApplicationContext.java:770)
05-17 15:16:30.572: ERROR/ActivityThread(17448): at android.app.ApplicationContext.registerReceiver(ApplicationContext.java:757)
05-17 15:16:30.572: ERROR/ActivityThread(17448): at android.app.ApplicationContext.registerReceiver(ApplicationContext.java:751)
05-17 15:16:30.572: ERROR/ActivityThread(17448): at android.content.ContextWrapper.registerReceiver(ContextWrapper.java:290)
05-17 15:16:30.572: ERROR/ActivityThread(17448): at android.net.NetworkConnectivityListener.startListening(NetworkConnectivityListener.java:138)
05-17 15:16:30.572: ERROR/ActivityThread(17448): at com.google.android.maps.MapActivity.onResume(MapActivity.java:232)
05-17 15:16:30.572: ERROR/ActivityThread(17448): at android.app.Instrumentation.callActivityOnResume(Instrumentation.java:1225)
05-17 15:16:30.572: ERROR/ActivityThread(17448): at android.app.Activity.performResume(Activity.java:3559)
05-17 15:16:30.572: ERROR/ActivityThread(17448): at android.app.ActivityThread.performResumeActivity(ActivityThread.java:2838)
05-17 15:16:30.572: ERROR/ActivityThread(17448): at android.app.ActivityThread.handleResumeActivity(ActivityThread.java:2866)
05-17 15:16:30.572: ERROR/ActivityThread(17448): at android.app.ActivityThread$H.handleMessage(ActivityThread.java:1819)
05-17 15:16:30.572: ERROR/ActivityThread(17448): at android.os.Handler.dispatchMessage(Handler.java:99)
05-17 15:16:30.572: ERROR/ActivityThread(17448): at android.os.Looper.loop(Looper.java:123)
05-17 15:16:30.572: ERROR/ActivityThread(17448): at android.app.ActivityThread.main(ActivityThread.java:4203)
05-17 15:16:30.572: ERROR/ActivityThread(17448): at java.lang.reflect.Method.invokeNative(Native Method)
05-17 15:16:30.572: ERROR/ActivityThread(17448): at java.lang.reflect.Method.invoke(Method.java:521)
05-17 15:16:30.572: ERROR/ActivityThread(17448): at com.android.internal.os.ZygoteInit$Method开发者_Go百科AndArgsCaller.run(ZygoteInit.java:791)
05-17 15:16:30.572: ERROR/ActivityThread(17448): at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:549)
05-17 15:16:30.572: ERROR/ActivityThread(17448): at dalvik.system.NativeStart.main(Native Method)
What is the Activity Thread Exception in Android? Please Help.
I got the same problem and after searching I found this post about the same issue
https://novoda.lighthouseapp.com/projects/63622/tickets/157-leak-receiver-searchresult
it suggests that the problem rises when using multiple map activities
within your application.
so in manifest.xml file of my app I made each map activity run in a separate process:
android:process=":p1"
android:process=":p2"
you can read more about this in Android docs. http://developer.android.com/guide/topics/manifest/activity-element.html#proc
You have your answer in the exception log..
Are you missing a call to unregisterReceiver()?
Did you register a broadcast receiver in your application?If yes you should call unregister receiver before destroy your activity.
EDIT
Hi..
i had a look at ConnectivityBroadcastReceiver and i found this discussions..
on Android Developers
on android google code
they have the same problem..could you post your code?
I encountered this problem also. For my case, I uses a battery indicator and did not destroy it when onPause() or onDestroy(). Just found out that the battery indicator is a broadcast receiver.
To solve I did the following:
@Override
public void onPause()
{
super.onPause();
unregisterReceiver(myBatInfoReceiver);
}
@Override
public void onResume()
{
super.onResume();
registerReceiver(myBatInfoReceiver,
new IntentFilter(Intent.ACTION_BATTERY_CHANGED));
}
精彩评论