【Android-删除指定包名的App】知识就是力量,时间就是生命。这篇文章主要讲述Android-删除指定包名的App相关的知识,希望能为你提供帮助。
/** * check and delete the old package app if it exists. */ private void checkOldPackage() { String packageName = "xxx.xxx.xxx.xxx"; if (isAvilible(this, packageName)) { Intent uninstall_intent = new Intent(); uninstall_intent.setAction(Intent.ACTION_DELETE); uninstall_intent.setData(Uri.parse("package:" + packageName)); startActivity(uninstall_intent); } }private boolean isAvilible(Context cxt, String packagename) { PackageManager pm = cxt.getPackageManager(); List< PackageInfo> pinfo = pm.getInstalledPackages(0); for (int i = 0; i < pinfo.size(); i++) { if (pinfo.get(i).packageName.equalsIgnoreCase(packagename)) { return true; } } return false; }
1.查找是否存在指定包名的App
2.创建Intent,删除指定包名的App
推荐阅读
- [Android基础]Android中使用HttpURLConnection
- Android中的Telephony学习笔记
- Android Studio - 第四十五期 Gradle manifestPlaceholders
- 如何在macOS上安装CodeIgniter
- 如何在MacOS上安装CakePHP
- 如何在MacOS上安装BlueFish
- 如何在MacOS上安装XAMPP
- 如何在MacOS上安装Vim
- 如何在MacOS上安装PyCharm