Android之解决android9.0通过Inten方式卸载APP没反应
1 问题
通过Intent卸载APP在安卓9.0手机上没反应,也没报错,卸载相关APP跳转到卸载页面代码
fun unInstallApp(packageName: String) {
val uri: Uri = Uri.fromParts("package", packageName, null)
val intent = Intent(Intent.ACTION_DELETE, uri)
intent.addFlags(Intent.FLAG_ACTIVITY_NEW_TASK);
startActivity(intent)
}
public void unInstallApp(Context context,String packageName) {
Intent intent = new Intent(Intent.ACTION_DELETE);
intent.setData(Uri.parse("package:" + packageName));
intent.addFlags(Intent.FLAG_ACTIVITY_NEW_TASK);
context.startActivity(intent);
}
2 解决办法
在AndroidManifest.xml中添加如下权限
<uses-permissionandroid:name="android.permission.REQUEST_DELETE_PACKAGES"/>
赞 (0)