2

I have a system app running on android 8.1 and it will uninstall app if the other app is installed by my app otherwise it is not uninstalling and other method is showing uninstall popup in it.

PackageManager pm = ctx.getPackageManager();
        PackageInstaller pi = null;
        Intent intent = new Intent(ctx, ctx.getClass());
        PendingIntent alarmtest = PendingIntent.getBroadcast(ctx,
                1337111117, intent, PendingIntent.FLAG_UPDATE_CURRENT);
        if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.LOLLIPOP) {
            pi = pm.getPackageInstaller();
            try {
                pi.uninstall(appName.toString().trim(), alarmtest.getIntentSender());
            } catch (Exception ex) {
                Log.d(Utils.TAG, "Uninstall app", ex);
            }

Any other method for uninstall using system app

Vivek Gupta
  • 349
  • 1
  • 2
  • 15

1 Answers1

1

There's a really good answer about different approaches here on another Stack Overflow thread: install / uninstall APKs programmatically (PackageManager vs Intents)

cmota
  • 914
  • 6
  • 7
  • I have already followed this and also used reflection to uninstall the app and it is not working and for rooted one i can not use now as device is not rooted – Vivek Gupta Jan 03 '19 at 11:03
  • It does not get any error it silently do not give any response in it – Vivek Gupta Jan 05 '19 at 13:06