Unregistering receiver in onStart/Stop vs onCreate/Destroy. (Bug 16513124)

Change-Id: I11ccc3cea41311d74811dc19e6950da3bbddbfe2
This commit is contained in:
Winson Chung
2014-07-31 18:40:03 -07:00
committed by Winson Chung
parent be0f59ea65
commit 19fc117c2f
2 changed files with 20 additions and 4 deletions

View File

@@ -383,9 +383,6 @@ public class RecentsActivity extends Activity implements RecentsView.RecentsView
filter.addAction(SearchManager.INTENT_GLOBAL_SEARCH_ACTIVITY_CHANGED);
registerReceiver(mSystemBroadcastReceiver, filter);
// Register any broadcast receivers for the task loader
RecentsTaskLoader.getInstance().registerReceivers(this, mRecentsView);
// Private API calls to make the shadows look better
try {
Utilities.setShadowProperty("ambientShadowStrength", String.valueOf(35f));
@@ -451,6 +448,9 @@ public class RecentsActivity extends Activity implements RecentsView.RecentsView
filter.addAction(ACTION_TOGGLE_RECENTS_ACTIVITY);
filter.addAction(ACTION_START_ENTER_ANIMATION);
registerReceiver(mServiceBroadcastReceiver, filter);
// Register any broadcast receivers for the task loader
RecentsTaskLoader.getInstance().registerReceivers(this, mRecentsView);
}
@Override
@@ -481,9 +481,15 @@ public class RecentsActivity extends Activity implements RecentsView.RecentsView
protected void onStop() {
super.onStop();
// Remove all the views
mRecentsView.removeAllTaskStacks();
// Unregister the RecentsService receiver
unregisterReceiver(mServiceBroadcastReceiver);
// Unregister any broadcast receivers for the task loader
RecentsTaskLoader.getInstance().unregisterReceivers();
// Stop listening for widget package changes if there was one bound
if (mAppWidgetHost.isListening()) {
mAppWidgetHost.stopListening();
@@ -496,7 +502,6 @@ public class RecentsActivity extends Activity implements RecentsView.RecentsView
// Unregister the system broadcast receivers
unregisterReceiver(mSystemBroadcastReceiver);
RecentsTaskLoader.getInstance().unregisterReceivers();
}
@Override

View File

@@ -121,6 +121,17 @@ public class RecentsView extends FrameLayout implements TaskStackView.TaskStackV
}
}
/** Removes all the task stack views from this recents view. */
public void removeAllTaskStacks() {
int childCount = getChildCount();
for (int i = childCount - 1; i >= 0; i--) {
View child = getChildAt(i);
if (child != mSearchBar) {
removeViewAt(i);
}
}
}
/** Launches the focused task from the first stack if possible */
public boolean launchFocusedTask() {
// Get the first stack view