How to check whether an application can be uninstalled?
I use the PackageManager to get the list o开发者_如何学Gof installed Android applications. But some stock applications cannot be uninstalled from the device. How do I check for those programmatically?
Intent i = new Intent(Intent.ACTION_MAIN, null);
i.addCategory(Intent.CATEGORY_LAUNCHER);
PackageManager pm = this.getPackageManager();
List<ResolveInfo> activities = pm.queryIntentActivities
(i, PackageManager.PERMISSION_GRANTED);
System applications cannot be uninstalled, so check if an application is a system app using the Package Manager and then proceed.
精彩评论