Register ContentObserver when activity is started
The ContentObserver was registered only when the activity was in resumed state. However, in started but paused state (when the activity is visible but not in focus), we still want to receive these notifications to update the view. Therefore, register it on start and unregister it on stop. As a consequence, myAppObserver will be non-null during onActivityResult().
This commit is contained in:
parent
4e2ab4c048
commit
cda80f5de6
@ -468,15 +468,19 @@ public class AppDetails extends ActionBarActivity implements ProgressListener, A
|
||||
private String mInstalledSigID;
|
||||
|
||||
@Override
|
||||
protected void onResume() {
|
||||
super.onResume();
|
||||
|
||||
protected void onStart() {
|
||||
super.onStart();
|
||||
// register observer to know when install status changes
|
||||
myAppObserver = new AppObserver(new Handler());
|
||||
getContentResolver().registerContentObserver(
|
||||
AppProvider.getContentUri(app.id),
|
||||
true,
|
||||
myAppObserver);
|
||||
}
|
||||
|
||||
@Override
|
||||
protected void onResume() {
|
||||
super.onResume();
|
||||
if (downloadHandler != null) {
|
||||
if (downloadHandler.isComplete()) {
|
||||
downloadCompleteInstallApk();
|
||||
@ -521,12 +525,14 @@ public class AppDetails extends ActionBarActivity implements ProgressListener, A
|
||||
}
|
||||
}
|
||||
|
||||
protected void onStop() {
|
||||
super.onStop();
|
||||
getContentResolver().unregisterContentObserver(myAppObserver);
|
||||
}
|
||||
|
||||
@Override
|
||||
protected void onPause() {
|
||||
super.onPause();
|
||||
if (myAppObserver != null) {
|
||||
getContentResolver().unregisterContentObserver(myAppObserver);
|
||||
}
|
||||
if (app != null && (app.ignoreAllUpdates != startingIgnoreAll
|
||||
|| app.ignoreThisUpdate != startingIgnoreThis)) {
|
||||
Log.d(TAG, "Updating 'ignore updates', as it has changed since we started the activity...");
|
||||
|
Loading…
x
Reference in New Issue
Block a user