I’m going to uninstall an application when user click on a button. with this code:
Uri packageURI = Uri.parse("package:"
+ pkNames[position]);
Intent uninstallIntent = new Intent(
Intent.ACTION_DELETE, packageURI);
context.startActivity(uninstallIntent);
but some application don’t uninstallable. like Setting or Music or … when i am going to uninstall these applications i see : uninstall not successful.
I get my packages with this code :
Intent mainIntent = new Intent(Intent.ACTION_MAIN, null);
mainIntent.addCategory(Intent.CATEGORY_LAUNCHER);
packages = pm.queryIntentActivities(mainIntent, 0);
How can i detect an application is uninstallable or not?
You should check if the application you are trying to uninstall is “system” by looking into
ApplicationInfo.flags. System application haveApplicationInfo.FLAG_SYSTEMbit set.Here is a little piece of code:
Check documentation for ApplicationInfo class for other useful flags.