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