The following snippet, called from my implementation of onOptionsItemSelected()
, works nicely to carry the user from my app to a mail client with email address, subject and body pre-filled. I'm using this as a simple way to let the user give me feedback.
String uriText =
"mailto:" + emailAddress +
"?subject=" + subject +
"&body=" + body;
Intent emailIntent = new Intent(Intent.ACTION_SENDTO, Uri.parse(uriText));
startActivity(Intent.createChooser(emailIntent, "Pick an email app:"));
When the mail app opens (on my Nexus S with Android 4.0.4), LogCat outputs the following, and I can't figure out why; Google and SO searches for createChooser unregisterReceiver seem fruitless, and I can't find many examples of createChooser()
that also call unregisterReceiver()
in a way that helps this situation.
04-08 21:26:19.094: E/ActivityThread(27894): Activity com.android.internal.app.ChooserActivity has leaked IntentReceiver com.android.internal.app.ResolverActivity$1@4150aac8 that was originally registered here. Are you missing a call to unregisterReceiver()?
04-08 21:26:19.094: E/ActivityThread(27894): android.app.IntentReceiverLeaked: Activity com.android.internal.app.ChooserActivity has leaked IntentReceiver com.android.internal.app.ResolverActivity$1@4150aac8 that was originally registered here. Are you missing a call to unregisterReceiver()?
04-08 21:26:19.094: E/ActivityThread(27894): at android.app.LoadedApk$ReceiverDispatcher.(LoadedApk.java:763)
This feels like an Android bug because my own code doesn't call registerReceiver()
, so why is Android complaining that I need to call unregisterReceiver()
?