1

We have in-app update feature were we use installPackage() of PackageManager to install new update of the app.

This is working most of the time. But at times we're facing an issue were app version is change but App UI & code is not. I can see that App version updated from the API request but UI didn't change and API request are same as old version.

public UpdateManager(Context context) throws SecurityException, NoSuchMethodException {

        observer = new PackageInstallObserver();
        pm = context.getPackageManager();

        Class<?>[] types = new Class[]{Uri.class, IPackageInstallObserver.class, int.class, String.class};
        method = pm.getClass().getMethod("installPackage", types);
    }

public void installPackage(File apkFile) throws IllegalArgumentException, IllegalAccessException, InvocationTargetException {
        if (!apkFile.exists()) throw new IllegalArgumentException();
        Uri packageURI = Uri.fromFile(apkFile);
        installPackage(packageURI);
    }

public void installPackage(Uri apkFile) throws IllegalArgumentException, IllegalAccessException, InvocationTargetException {
        method.invoke(pm, new Object[]{apkFile, observer, INSTALL_REPLACE_EXISTING, null});
    }

This app has system permissions (INSTALL_PACKAGES).

Any help would be appreciated.

Shahal
  • 1,008
  • 1
  • 11
  • 29

0 Answers0