有 Java 编程相关的问题?

你可以在下面搜索框中键入要查询的问题!

java共享映像无法运行Android 6.0

我有一个安卓应用程序,它具有共享图像功能以及保存图像。除了安卓 6.0之外,这些功能在其他系统中运行良好。当我尝试与whatsapp以及其他应用程序共享图像时,图像不会被附加。我的分享图片的java代码如下。我应该纠正什么来解决这个问题? 感谢朋友们的支持:)

protected String doInBackground(String... args) { try { myFileUrl = new URL(args[0]); //myFileUrl1 = args[0]; HttpURLConnection conn = (HttpURLConnection) myFileUrl.openConnection(); conn.setDoInput(true); conn.connect(); InputStream is = conn.getInputStream(); bmImg = BitmapFactory.decodeStream(is); } catch (IOException e) { e.printStackTrace(); } try { String path = myFileUrl.getPath(); String idStr = path.substring(path.lastIndexOf('/') + 1); File filepath = Environment.getExternalStorageDirectory(); File dir = new File(filepath.getAbsolutePath() + "/Hindi Picture/"); dir.mkdirs(); String fileName = idStr; file = new File(dir, fileName); FileOutputStream fos = new FileOutputStream(file); bmImg.compress(CompressFormat.JPEG, 75, fos); fos.flush(); fos.close(); } catch (Exception e) { e.printStackTrace(); } return null; } @Override protected void onPostExecute(String args) { Intent share = new Intent(Intent.ACTION_SEND); share.setType("image/jpeg"); share.putExtra(Intent.EXTRA_STREAM, Uri.parse("file://" + file.getAbsolutePath())); startActivity(Intent.createChooser(share, "Share Image")); pDialog.dismiss(); } }); }

共 (0) 个答案