【问题标题】:Android: Sharing Bitmap with Intents on other appsAndroid:在其他应用程序上与 Intents 共享位图
【发布时间】:2015-01-18 15:07:26
【问题描述】:

我有一个使用 Android Query 创建的位图文件:

aq = new AQuery(HomeCategoryActivity.this);
aq.ajax(currentUrl,Bitmap.class,0,new AjaxCallback<Bitmap>(){
        @Override
        public void callback(String url, Bitmap object, AjaxStatus status) {
            if(object != null)
            {
                bmp = object;
            }
        }
    });

bmp 是一个全局初始化的变量,它被上面的代码正确保存,而不是 NULL,我检查了。

现在我想用这个在其他应用程序上分享这个位图:

Intent intent = new Intent(Intent.ACTION_SEND);
intent.setType("image/jpeg");
intent.putExtra(Intent.EXTRA_STREAM, Uri.fromFile(bmp));
startActivity(Intent.createChooser(intent, "Share Product via:"));

这不起作用,因为代码可能是错误的。我应该做出哪些改变?

我想在 Fb、insta 等上分享图片

【问题讨论】:

  • 如果您只想将位图从一个活动发送到另一个活动,请在下面的链接中查看选定的答案:stackoverflow.com/questions/11010386/…
  • 我想在 fb 或 insta @AADTechnical 等社交网络上分享它

标签: java android android-intent bitmap android-sharing


【解决方案1】:

将位图保存到外部存储并获取位图图像的路径

然后将Uri.parse(path)传递给意图。

欲了解更多信息,请参阅此链接http://developer.android.com/training/sharing/send.html

Intent intent = new Intent(Intent.ACTION_SEND);
    intent.setType("image/jpeg");
    intent.putExtra(Intent.EXTRA_STREAM, Uri.parseUri(path));
    startActivity(Intent.createChooser(intent, "Share Product via:"));

【讨论】:

    猜你喜欢
    • 1970-01-01
    • 2012-06-14
    • 2014-12-19
    • 1970-01-01
    • 1970-01-01
    • 2016-09-09
    • 1970-01-01
    • 2017-03-19
    • 2016-02-08
    相关资源
    最近更新 更多