我从Json获取图像并将其显示在gridview中。在选择图像时,图像会放大到全屏,并且共享选项可用。当我点击共享选项时,在API 22以上的手机上,加载栏不会被解雇。它适用于棒棒糖。不知道为什么它不在Marshmallow工作。
这是代码
public void share(View view){
// Get access to the URI for the bitmap
pDialog = new ProgressDialog(Displaydemo.this);
pDialog.setMessage("Loading...");
pDialog.show();
niv1 = (NetworkImageView) findViewById(R.id.imgNetwork);
Uri bmpUri = getLocalBitmapUri(niv1);
if (bmpUri != null) {
pDialog.dismiss();
Intent shareIntent = new Intent();
shareIntent.setAction(Intent.ACTION_SEND);
shareIntent.putExtra(Intent.EXTRA_STREAM, bmpUri);
shareIntent.putExtra(Intent.EXTRA_SUBJECT,"share");
shareIntent.putExtra(Intent.EXTRA_TEXT,Datas.Address );
shareIntent.setType("image/*");
startActivity(Intent.createChooser(shareIntent, "Share Image"));
}
}
答案 0 :(得分:1)
看起来您正面临mashmallow运行时权限问题。请参阅此帖Android 6: cannot share files anymore?
此外,如果使用v4支持库,则应使用ShareCompat进行共享https://medium.com/google-developers/sharing-content-between-android-apps-2e6db9d1368b#.wnlh9s3n7
答案 1 :(得分:0)
字符串路径= Environment.getExternalStorageDirectory()+ File.separator + File.separator + file_name;
文件file_ =新文件(路径);
private void shareFile(File file_){ Intent intentShareFile = new Intent(Intent.ACTION_SEND);
intentShareFile.setType(URLConnection.guessContentTypeFromName(file_.getName()));
intentShareFile.putExtra(Intent.EXTRA_STREAM,
Uri.parse("file://"+file_.getAbsolutePath()));
startActivity(Intent.createChooser(intentShareFile, "Share File"));
}