【问题标题】:Sharing button don't run with the facebook (Text Empty)共享按钮不与 facebook 一起运行(文本为空)
【发布时间】:2018-04-27 06:26:59
【问题描述】:

共享按钮与 Viber 和 What's 应用程序一起运行 但不要使用 Facebook, 只是空白区域。

Intent myIntent = new Intent(Intent.ACTION_SEND);
bt = findViewById(R.id.imageShareButton);
        bt.setOnClickListener(new View.OnClickListener() {
            public void onClick(View v) {
                String shareBody = versesText.getText().toString();
                myIntent.setType("text/plain");
                myIntent.putExtra(Intent.EXTRA_SUBJECT, "Perfect Verses");
                myIntent.putExtra(Intent.EXTRA_TEXT, shareBody + "\n" + "Read More...");
                myIntent.putExtra(Intent.EXTRA_TEXT, shareBody);
                startActivity(Intent.createChooser(myIntent, getResources().getString(R.string.app_name)));
             }
         });

我的应用在 GooglePlay 上的链接, https://play.google.com/store/apps/details?id=com.samuel.perfectverses

【问题讨论】:

  • 您是否已经尝试过this question 上发布的解决方案?
  • 此问题将按设计关闭,因为我们的 API 不支持为用户预先填写消息,如我们的政策文档中所述
  • 我认为这是不可能的..这很可悲:(
  • 您需要使用 Facebook 的 SDK 来允许在他们的应用上分享。你可以阅读官方文档here

标签: android android-studio android-intent share


【解决方案1】:

here我运行你的代码得到了这个,我想你忘了添加动作。

val sharingIntent = Intent(Intent.ACTION_SEND)
sharingIntent.type = "text/plain"
sharingIntent.putExtra(Intent.EXTRA_SUBJECT, "subject")
sharingIntent.putExtra(Intent.EXTRA_STREAM, titl + "\n" + "Read More..." + "\n" + link)
startActivity(Intent.createChooser(sharingIntent, getResources().getString(R.string.app_name)))

【讨论】:

  • 实际上我之前添加了发送操作,但它不适用于 Facebook。我通过您发送的一些代码更新了有问题的代码,但它也不适用于 Facebook。它仅适用于 Gmail 和 Viber。
  • @samuel 我试过你的代码,它工作正常,我更新了图像。你在哪个设备上测试?
  • 三星 Note 5 和 HTC Desire 728 Ultra。
  • 它与 Facebook 合作吗?还是在“你在想什么”里面放一个文字
  • 如果您想测试我的应用程序,我已将其发布给您
【解决方案2】:
String packageName = "com.facebook.katana";
String fullUrl = "https://m.facebook.com/sharer.php?u=..";
        Intent intent = getPackageManager().getLaunchIntentForPackage(packageName);
        if (intent == null) {
            Intent i = new Intent(Intent.ACTION_VIEW);
            i.setData(Uri.parse(fullUrl));
            startActivity(i);
        } else {
            Intent sharingIntent = new Intent(Intent.ACTION_SEND);
            sharingIntent.setClassName(packageName ,
                    "com.facebook.katana.ShareLinkActivity");
            sharingIntent.putExtra(Intent.EXTRA_TEXT, "your title text");
            startActivity(sharingIntent);

【讨论】:

  • 我试过这个链接,但它只适用于 url,不适用于文本。我认为这是 Facebook 验证。
猜你喜欢
  • 1970-01-01
  • 1970-01-01
  • 1970-01-01
  • 1970-01-01
  • 1970-01-01
  • 2013-11-26
  • 1970-01-01
  • 1970-01-01
  • 1970-01-01
相关资源
最近更新 更多