【问题标题】:Send Bitmap using data URI scheme使用数据 URI 方案发送位图
【发布时间】:2015-03-28 16:38:43
【问题描述】:

我正在尝试另一种方法来解决这个问题:Share image without WRITE_EXTERNAL_STORAGE?

我的想法是在data URI scheme 中编码一个PNG。我的代码:

ByteArrayOutputStream baos = new ByteArrayOutputStream();
baos.write("data:image/png;base64,".getBytes());
Base64OutputStream base64 = new Base64OutputStream(baos, Base64.NO_WRAP);
boolean ok = bitmap.compress(Bitmap.CompressFormat.PNG, 0, base64);
base64.close();
if (ok) {
    Uri uri = Uri.parse(baos.toString());
    Intent intent = new Intent(Intent.ACTION_SEND);
    intent.setType("image/png");
    intent.putExtra(Intent.EXTRA_STREAM, uri);
    startActivity(intent);
}

我尝试过的应用程序(例如 Android 4.4.4 上的 Gmail)说它们无法打开图像。 我是否正确创建了我的Uri?如果是这样,是什么阻止了其他应用程序读取我的图像?

【问题讨论】:

    标签: android


    【解决方案1】:

    我的 Uri 创建是否正确?

    我不知道。

    如果是这样,是什么阻止了其他应用程序读取我的图像?

    因为他们不知道如何处理 data Uri

    【讨论】:

      猜你喜欢
      • 2011-10-12
      • 2013-11-06
      • 1970-01-01
      • 2021-04-30
      • 1970-01-01
      • 1970-01-01
      • 2019-11-20
      • 1970-01-01
      • 1970-01-01
      相关资源
      最近更新 更多