【问题标题】:android ACTION_SEND image and textandroid ACTION_SEND 图片和文字
【发布时间】:2013-05-29 09:24:43
【问题描述】:

我想从我的应用程序中向 facebook 和其他应用程序发送图像和一些文本,以便用户可以共享它们。目前我放置了文本和图像 URI,但是当我选择 facebook 时,只发送图像。在 WhatsApp 中也只发送图像。在 Google+ 应用程序中,图像和文本都被传递。有人可以告诉我正确的方向吗?

代码示例(我这里现在没有原始代码,也许我会稍后发布)

Intent shareIntent = new Intent();
shareIntent.setAction(Intent.ACTION_SEND);
shareIntent.putExtra(Intent.EXTRA_STREAM, uriToImage);
shareIntent.setType("image/png");
shareIntent.putExtra(Intent.EXTRA_TEXT , myText);
startActivity(Intent.createChooser(shareIntent, "Choose an app" ));

如果我将 ACTION_SEND 更改为 ACTION_SEND_MULTIPLE,那么它根本不起作用。如果我将类型更改为“text/plain”或 html,则文本会发送到 whatsapp、google+ 和 Facebook Messenger,但不会在普通 Facebook 应用程序中(它会打开一个空的共享对话框)。

【问题讨论】:

    标签: android facebook image post text


    【解决方案1】:

    你应该使用下面的行

               Intent sendIntent = new Intent(Intent.ACTION_SEND);
                sendIntent.setType("image/*");
                sendIntent.putExtra(Intent.EXTRA_SUBJECT, "My image");
               sendIntent.putExtra(Intent.EXTRA_STREAM, Uri.fromFile(new File(filename_toshare)));// this is for image . here filename_toshare is your file path.
                sendIntent.putExtra(Intent.EXTRA_TEXT, "My Image ");// this is for text
                startActivity(Intent.createChooser(sendIntent, "Email:"));  
    

    希望这对您有所帮助。

    【讨论】:

    • 这段代码意味着通过添加“EXTRA_SUBJECT”,我的“EXTRA_TEXT”也会被发送?因为我没有看到您的代码和我的代码之间有任何其他实际差异。
    • 实际上在 facebook 中,您不能通过 action send 或 actionsend multiple 从应用程序发送任何文本,因为这是 facebook 中的已知错误。但您可以将文本发送到 twitter、g+、gmail 等。这取决于应用程序.. 像什么应用程序也不允许我们从我们的应用程序发送文本。我们需要在那里输入。
    • 有什么解决方法吗?也许直接使用 facebook Graph API?
    猜你喜欢
    • 2013-01-08
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 2015-07-24
    • 1970-01-01
    • 1970-01-01
    • 2013-08-04
    • 2021-12-25
    相关资源
    最近更新 更多