美文网首页
AndroidPie(9)使用Intent卸载应用无任何反应解决

AndroidPie(9)使用Intent卸载应用无任何反应解决

作者: 阿闯学长 | 来源:发表于2019-02-13 14:40 被阅读36次

android9.0卸载应用

首先使用下面代码在安卓9.0并不管用

    /**
     * 卸载
     *
     * @param context     上下文
     * @param packageName 包名
     */
    public static void delete(Context context, String packageName) {
        Uri uri = Uri.parse("package:" + packageName);
        Intent intent = new Intent(Intent.ACTION_DELETE, uri);
        context.startActivity(intent);
    }

是因为没有加权限
在manifest加入下面一句话

<uses-permission android:name="android.permission.REQUEST_DELETE_PACKAGES" />

相关文章

网友评论

      本文标题:AndroidPie(9)使用Intent卸载应用无任何反应解决

      本文链接:https://www.haomeiwen.com/subject/iicdeqtx.html