Unable to receive share image - Android 6.0

谁说我不能喝 提交于 2019-12-02 04:55:36

You cannot and should not attempt to ever get the underlying path corresponding with a URI - in the vast majority of cases your app will never have access to the path itself, but only through the URI.

Thankfully, you can get the binary data of the image from the URI directly:

InputStream in;
Bitmap bitmap = null;
try {
  in = getContentResolver().openInputStream(imageUri);
  // You could do anything with the InputStream.
  // Here we'll just get the Bitmap at full size
  bitmap = BitmapFactory.decodeStream(in);
} catch (IOException e) {
  // Something went wrong
} finally {
  if (in != null) {
    try {
      in.close();
    } catch (IOException ignored) {}
  }
}
// Now you have a Bitmap.
易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!