android读写存储及uri相关

2019-09-29  本文已影响0人  Fakecoder_Sunis

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);
上一篇 下一篇

猜你喜欢

热点阅读