Commit 47e06544 authored by Romain Vimont's avatar Romain Vimont

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
#135
parent 07005489
......@@ -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);
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment