美文网首页
android读写存储及uri相关

android读写存储及uri相关

作者: Fakecoder_Sunis | 来源:发表于2019-09-29 14:19 被阅读0次

    see

    启动安装 最好使用下面 更保险

    intent.setDataAndType(uri, "application/vnd.android.package-archive");
            if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.N) {
                List<ResolveInfo> resInfoList = mContext.getPackageManager().queryIntentActivities(intent, PackageManager.MATCH_DEFAULT_ONLY);
                for (ResolveInfo resolveInfo : resInfoList) {
                    Log.e("update", resolveInfo.activityInfo.packageName);
                    String packageName = resolveInfo.activityInfo.packageName;
                    mContext.grantUriPermission(packageName, uri, Intent.FLAG_GRANT_WRITE_URI_PERMISSION | Intent.FLAG_GRANT_READ_URI_PERMISSION);
                }
            }
            mContext.startActivity(intent);
    

    相关文章

      网友评论

          本文标题:android读写存储及uri相关

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