List of usage examples for android.content.pm PackageManager deletePackage
@RequiresPermission(Manifest.permission.DELETE_PACKAGES) @UnsupportedAppUsage public abstract void deletePackage(String packageName, IPackageDeleteObserver observer, @DeleteFlags int flags);
From source file:org.wso2.emm.system.service.utils.AppUtils.java
/** * Silently uninstalls the app resides in the provided URI. * @param context - Application context. * @param packageName - App package name. *///from w w w .j a v a 2 s. c o m public static void silentUninstallApp(Context context, String packageName) { if (packageName != null && packageName.contains(PACKAGE_PREFIX)) { packageName = packageName.replace(PACKAGE_PREFIX, ""); } final String _packageName = packageName; PackageManager pm = context.getPackageManager(); IPackageDeleteObserver observer = new IPackageDeleteObserver() { @Override public void packageDeleted(String s, int i) throws RemoteException { Log.d(TAG, _packageName + " deleted successfully."); } @Override public IBinder asBinder() { return null; } }; pm.deletePackage(packageName, observer, DELETE_ALL_USERS); }