简体   繁体   中英

How to uninstall the app from listview in android

Greeting everyone!! I am creating an android application on it i have to make an option of uninstalling the installed application.

I have listed the installed application using the following code.

Here is my code.

 packageManager = getPackageManager();
 List<ApplicationInfo> list = packageManager.getInstalledApplications(PackageManager.GET_META_DATA);
 PACKAGENAME = getApplicationContext().getPackageName();
 new LoadApplications().execute();

But i don't know how to uninstall the apps by presenting my code on OnClickListener.

Please give me some suggestion.

String packageNameOfAppToUninstall = "org.abc.test"; 
Uri packageUri = Uri.parse("package:" + packageNameOfAppToUninstall);
Intent uninstallIntent = new Intent(Intent.ACTION_UNINSTALL_PACKAGE, packageUri);
startActivity(uninstallIntent);

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM