android 调用系统分享微信失败:获取资源失败。
解决方案:全网仅此一家,别无分店
Intent shareIntent =new Intent();
shareIntent.addFlags(Intent.FLAG_GRANT_READ_URI_PERMISSION | Intent.FLAG_GRANT_WRITE_URI_PERMISSION);
shareIntent.setAction(Intent.ACTION_SEND);
ApplicationInfo applicationInfo = getApplicationInfo();
int targetSDK = applicationInfo.targetSdkVersion;
Uri uri;
if (targetSDK >= Build.VERSION_CODES.N && Build.VERSION.SDK_INT >= Build.VERSION_CODES.N) {
uri = Uri.parse(android.provider.MediaStore.Images.Media.insertImage(getContentResolver(),
writeFile.getAbsolutePath(), chalkBean.getName(), null));
}else{
uri = Uri.fromFile(new File(writeFile.getPath()));
}
shareIntent.putExtra(Intent.EXTRA_STREAM, uri);
shareIntent.setType("image/*");
startActivity(Intent.createChooser(shareIntent, "分享到:"));