My favorites | Sign in
Project Home Issues
New issue   Search
for
  Advanced search   Search tips   Subscriptions
Issue 29399: Intent.createChooser() can cause a BroadcastReceiver leak
28 people starred this issue and may be notified of changes. Back to list
Status:  New
Owner:  ----


Sign in to add a comment
 
Reported by blazer...@gmail.com, Apr 23, 2012
If you call Intent.createChooser(), it will leak a BroadcastReceiver if there's only possible option.

Steps:

 * Use Intent.createChooser() to launch an intent that only has one possible option
 * The following stack trace will be logged to logcat:

E/ActivityThread( 2586): Activity com.android.internal.app.ChooserActivity has leaked IntentReceiver com.android.internal.app.ResolverActivity$1@41c8ede8 that was originally registered here. Are you missing a call to unregisterReceiver()?
E/ActivityThread( 2586): android.app.IntentReceiverLeaked: Activity com.android.internal.app.ChooserActivity has leaked IntentReceiver com.android.internal.app.ResolverActivity$1@41c8ede8 that was originally registered here. Are you missing a call to unregisterReceiver()?
E/ActivityThread( 2586): 	at android.app.LoadedApk$ReceiverDispatcher.<init>(LoadedApk.java:763)
E/ActivityThread( 2586): 	at android.app.LoadedApk.getReceiverDispatcher(LoadedApk.java:567)
E/ActivityThread( 2586): 	at android.app.ContextImpl.registerReceiverInternal(ContextImpl.java:1043)
E/ActivityThread( 2586): 	at android.app.ContextImpl.registerReceiver(ContextImpl.java:1030)
E/ActivityThread( 2586): 	at android.app.ContextImpl.registerReceiver(ContextImpl.java:1024)
E/ActivityThread( 2586): 	at android.content.ContextWrapper.registerReceiver(ContextWrapper.java:341)
E/ActivityThread( 2586): 	at com.android.internal.content.PackageMonitor.register(PackageMonitor.java:65)
E/ActivityThread( 2586): 	at com.android.internal.app.ResolverActivity.onCreate(ResolverActivity.java:99)
E/ActivityThread( 2586): 	at com.android.internal.app.ChooserActivity.onCreate(ChooserActivity.java:53)
E/ActivityThread( 2586): 	at android.app.Activity.performCreate(Activity.java:4465)
E/ActivityThread( 2586): 	at android.app.Instrumentation.callActivityOnCreate(Instrumentation.java:1049)
E/ActivityThread( 2586): 	at android.app.ActivityThread.performLaunchActivity(ActivityThread.java:1920)
E/ActivityThread( 2586): 	at android.app.ActivityThread.handleLaunchActivity(ActivityThread.java:1981)
E/ActivityThread( 2586): 	at android.app.ActivityThread.access$600(ActivityThread.java:123)
E/ActivityThread( 2586): 	at android.app.ActivityThread$H.handleMessage(ActivityThread.java:1147)
E/ActivityThread( 2586): 	at android.os.Handler.dispatchMessage(Handler.java:99)
E/ActivityThread( 2586): 	at android.os.Looper.loop(Looper.java:137)
E/ActivityThread( 2586): 	at android.app.ActivityThread.main(ActivityThread.java:4424)
E/ActivityThread( 2586): 	at java.lang.reflect.Method.invokeNative(Native Method)
E/ActivityThread( 2586): 	at java.lang.reflect.Method.invoke(Method.java:511)
E/ActivityThread( 2586): 	at com.android.internal.os.ZygoteInit$MethodAndArgsCaller.run(ZygoteInit.java:784)
E/ActivityThread( 2586): 	at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:551)
E/ActivityThread( 2586): 	at dalvik.system.NativeStart.main(Native Method)

Based on the current source, the problem appears to be that ResolverActivity is registering the receiver in onCreate(), but then calling finish() if there's only one option.  This causes the code to skip onStop(), which is where the receiver is unregistered.

Device:
Galaxy Nexus, 4.0.4

May 13, 2012
#1 anshua...@gmail.com
I found the same issue when calling cretaChooser. I was trying to send an email.
Jul 12, 2012
#2 manhhoan...@gmail.com
I have same error too. 
Please tell me how to fix this error
Thanks in advance!
Oct 18, 2012
#3 fabiolin...@gmail.com
I have same error too.
Now I solved without Intent.createChooser().
Oct 20, 2012
#4 sami.taipaleenmaki
This leak happens always if there is just one sender like SMS available.

Oct 31, 2012
#5 petojurk...@gmail.com
I have same issue when calling createChooser
Jul 15, 2013
#6 BarriePf...@gmail.com
I've just taken over some code which reference this issue.
Has it been resolved yet?
Do we know which versions are affected?
Jan 9, 2014
#7 gna...@wework.com
I'm able to replicate this issue on Android 4.4.0, HTC One
Jan 15, 2014
#8 cool2d...@gmail.com
I got the same issue on Android 4.4.2. Looking forward for solution from Google.
Feb 14, 2014
#9 vitaly.k...@gmail.com
I am seeing this issue on the latest ADT Emulator running on MacBookPro.

Android Developer Tools Build: v22.3.0-887826

Jun 24, 2014
#10 corentin...@gmail.com
Same issue when I want to retrieve a picture from the gallery using createChooser with Samsung Galaxy Tab 3 10.1. 
Is there a way to fix this issue?
Sign in to add a comment

Powered by Google Project Hosting