My design requires that I kill the get_configuration activity (Activity1) once the second_activity is running. However, when I hit the BACK button from the second_activity (Activity2), I get the following error:
“E/ActivityThread(2156): Activity com.test.Test has leaked IntentReceiver that was originally registered here. Are you missing a call to unregisterReceiver()?”
I’m new to Android, all my research mentions unregistering intent receivers – but I’m not using an intent receiver, just the intent to pass the bundle to the second_activity.
How do I unregister my intent from a destroyed activity? Here is the code I am using:-
Activity1 class:
SetupActivity() {
...
Intent intent = new Intent(getApplicationContext(), Activity2.class);
intent.putExtra("width", intWidth);
intent.putExtra("height", intHeight);
finish(); // kill this activity
startActivity(intent); // start Activity2
}
Activity2 class:
OnCreate() {
Bundle extras = getIntent().getExtras();
if (extras != null) {
width = extras.getInt("width");
height = extras.getInt("height");
}
}
You have a Java class. It is named
com.test.Test. In there, you have calledregisterReceiver(), yet failed to callunregisterReceiver()before it was destroyed.