卸载app¶
更新日期 2020-4-20
- 2020-4-20 创建文档
已知目标app的包名,可以申请卸载此app。
使用Intent.ACTION_DELETE
。
public static void uninstallAppByPkg(Context context, String pkg) {
try {
Intent intent = new Intent(Intent.ACTION_DELETE, Uri.fromParts("package", pkg, null));
intent.setFlags(Intent.FLAG_ACTIVITY_NEW_TASK);
context.startActivity(intent);
} catch (Exception e) {
Log.e(TAG, "uninstallAppByPkg: " + pkg, e);
}
}
作者: rustfisher.com | rf.cs@foxmail.com
示例: AndroidTutorial Gitee, Tutorial Github
本文链接: https://www.an.rustfisher.com/android/activity/uninstall-app/
一家之言,仅当抛砖引玉。如有错漏,还请指出。如果喜欢本站的内容,还请支持作者。也可点击1次下方的链接(链接内容与本站无关),谢谢支持服务器。
如有疑问,请与我联系:Android issues - gitee