John Roberts
John Roberts

Reputation: 5986

Leaked IntentReceiver

I have the following code in my onCreate():

registerReceiver(onComplete, new IntentFilter(DownloadManager.ACTION_DOWNLOAD_COMPLETE));

This line seems to be throwing the following error: Activity has leaked IntentReceiver that was originally registered here. Are you missing a call to unregisterReceiver()?.

I just don't see how this is possible though - I completely uninstall my app and then install it again, and this is the only receiver registration in the entire app. Does anyone know what's wrong?

Upvotes: 1

Views: 806

Answers (1)

Toon Borgers
Toon Borgers

Reputation: 3658

You need to unregister your receiver in onPause:

@Override
protected void onPause() {
  // Unregister since the activity is not visible
  LocalBroadcastManager.getInstance(this).unregisterReceiver(onComplete);
  super.onPause();
}

Upvotes: 2

Related Questions