Do not manually call onChange() (fix NPE)
If the AppDetails activity has been destroyed by the system during an application installation/remove, it is recreated once it should be displayed again (this behavior can be forced by enabling "Don't keep activities" in Android developer options). In onCreate(), it passes its instance of myInstallerCallback to an Installer. In onActivityResult() (which is called before onResume()), this installer calls a method (onSuccess() or onError()) on this callback. The implementation of these methods (the anonymous inner class assigned to myInstallerCallback) dereference myAppObserver, which is still null, because it will be initialized in onResume(), so a NullPointerException is thrown. However, the problem is not only that myAppObserver.onChange() is called when myAppObserver is null, but that it should not be called manually at all: it is a ContentObserver, so it is automatically called when registered to the content resolver. As a consequence, this callback was called twice. Removing these calls fix both problems. Should fix issue #135 https://gitlab.com/fdroid/fdroidclient/issues/135
This commit is contained in:
parent
070054892e
commit
47e065442e
@ -924,7 +924,6 @@ public class AppDetails extends ActionBarActivity implements ProgressListener, A
|
||||
}
|
||||
|
||||
setSupportProgressBarIndeterminateVisibility(false);
|
||||
myAppObserver.onChange();
|
||||
}
|
||||
});
|
||||
}
|
||||
@ -936,7 +935,6 @@ public class AppDetails extends ActionBarActivity implements ProgressListener, A
|
||||
@Override
|
||||
public void run() {
|
||||
setSupportProgressBarIndeterminateVisibility(false);
|
||||
myAppObserver.onChange();
|
||||
}
|
||||
});
|
||||
} else {
|
||||
@ -944,7 +942,6 @@ public class AppDetails extends ActionBarActivity implements ProgressListener, A
|
||||
@Override
|
||||
public void run() {
|
||||
setSupportProgressBarIndeterminateVisibility(false);
|
||||
myAppObserver.onChange();
|
||||
|
||||
Log.e(TAG, "Installer aborted with errorCode: " + errorCode);
|
||||
|
||||
|
Loading…
x
Reference in New Issue
Block a user