【问题标题】:How to share text into facebook using default android sharing(intent)?如何使用默认的 android 共享(意图)将文本共享到 facebook?
【发布时间】:2016-02-01 08:53:28
【问题描述】:

我正在处理所有默认可用应用程序中的文本共享,例如facebook、gmail..等。

这里我放了我的代码快照。

final Intent emailIntent1 = new Intent(
            android.content.Intent.ACTION_SEND);
    emailIntent1.setFlags(Intent.FLAG_ACTIVITY_NEW_TASK);
    emailIntent1.setAction("https://play.google.com/store");
    emailIntent1.putExtra(Intent.EXTRA_TEXT,"https://play.google.com/store");
    emailIntent1.setType("image/png");
    startActivity(Intent.createChooser(emailIntent1, "send"));

我的问题是,我无法在 facebook 上分享文字。

我们将不胜感激。

【问题讨论】:

标签: android facebook android-intent


【解决方案1】:

试试这个...

 Intent shareIntent = new Intent(Intent.ACTION_SEND);
        shareIntent.setType("text/plain");
        shareIntent.putExtra(Intent.EXTRA_SUBJECT, "Share this app");
        String shareMessage = "https://play.google.com/store";
        shareIntent.putExtra(Intent.EXTRA_TEXT, shareMessage);
        startActivity(Intent.createChooser(shareIntent, "Choose the messenger to share this App"));

【讨论】:

  • 这个是他想要的我猜.. +1
  • 它只适用于文本。但我也想共享位图 imageuri。我无法与位图 image.emailIntent1.putExtra(Intent.EXTRA_STREAM, bmpUri); 共享文本;
【解决方案2】:

试试这个代码。它将创建一个 Intent 选择器,列出设备上所有接受类型“text/plain”的已安装应用程序。

private void share(String text) {
    Intent shareIntent = new Intent(Intent.ACTION_SEND);
    shareIntent.setType("text/plain");
    shareIntent.putExtra(Intent.EXTRA_TEXT, text);
    startActivity(Intent.createChooser(shareIntent, "Share text"));
}

【讨论】:

    猜你喜欢
    • 2012-02-04
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 2012-06-07
    • 1970-01-01
    相关资源
    最近更新 更多