make sure uninstall process has an Apk instance
If a user clicks install, then uninstall on AppDetails, then there was not yet a chance to refresh the App instance, and therefore app.installedApk will still be null. This is really just a workaround for now, because AppDetails needs a full refactoring.
This commit is contained in:
parent
b8162a1a91
commit
e1a6c931c6
@ -29,6 +29,7 @@ import android.content.BroadcastReceiver;
|
||||
import android.content.Context;
|
||||
import android.content.DialogInterface;
|
||||
import android.content.Intent;
|
||||
import android.content.pm.PackageInfo;
|
||||
import android.content.pm.PackageManager;
|
||||
import android.database.ContentObserver;
|
||||
import android.graphics.Bitmap;
|
||||
@ -964,6 +965,18 @@ public class AppDetails extends AppCompatActivity {
|
||||
*/
|
||||
private void uninstallApk() {
|
||||
Apk apk = app.installedApk;
|
||||
if (apk == null) {
|
||||
// TODO ideally, app would be refreshed immediately after install, then this
|
||||
// workaround would be unnecessary
|
||||
try {
|
||||
PackageInfo pi = packageManager.getPackageInfo(app.packageName, 0);
|
||||
apk = ApkProvider.Helper.findApkFromAnyRepo(this, pi.packageName, pi.versionCode);
|
||||
app.installedApk = apk;
|
||||
} catch (PackageManager.NameNotFoundException e) {
|
||||
e.printStackTrace();
|
||||
return; // not installed
|
||||
}
|
||||
}
|
||||
Installer installer = InstallerFactory.create(this, apk);
|
||||
Intent intent = installer.getUninstallScreen();
|
||||
if (intent != null) {
|
||||
|
Loading…
x
Reference in New Issue
Block a user