简体   繁体   English

无法将Android应用中的内容共享到Facebook

[英]Cannot share content from Android app to Facebook

In my app, I intend to create a share button. 我打算在我的应用中创建一个共享按钮。 In fact, I want that if user clicks to this button, they will have options to share to Facebook, email, Twitter, Evernote, etc. depends on how many apps they have on their phone. 实际上,我希望如果用户单击此按钮,他们将可以选择共享到Facebook,电子邮件,Twitter,Evernote等。这取决于他们在手机上拥有多少个应用程序。

I implemented this piece of code: 我实现了这段代码:

btnShare.setOnClickListener(new OnClickListener() {
        @Override
        public void onClick(View view) {
            Intent sharingIntent = new Intent(Intent.ACTION_SEND);
            sharingIntent.setType("text/html");
            String sharingText = "I want to share this text.";
            sharingIntent.putExtra(Intent.EXTRA_TEXT, Html.fromHtml(sharingText));
            startActivity(Intent.createChooser(sharingIntent,"Share using"));
        }
    });

However, when I click to this button, I did not see option to share to Facebook, Google+ or Twitter. 但是,当我单击此按钮时,没有看到共享到Facebook,Google +或Twitter的选项。 I only saw dropbox, bluetooth, drive, email, evernote, gmail, onedrive. 我只看到了保管箱,蓝牙,驱动器,电子邮件,evernote,gmail,onedrive。 Although I already logged in to Facebook, G+ and Twitter on my device. 尽管我已经在设备上登录了Facebook,G +和Twitter。

Any one has some idea? 有人知道吗?

Thanks in advance. 提前致谢。

Try this 尝试这个

        btnShare.setOnClickListener(new OnClickListener() {
            @Override
            public void onClick(View view) {
                Intent sharingIntent = new Intent(Intent.ACTION_SEND);
                sharingIntent.setType("text/plain");
                String sharingText = "I want to share this text.";
                sharingIntent.putExtra(Intent.EXTRA_TEXT,sharingText);
                startActivity(Intent.createChooser(sharingIntent,"Share using"));
            }
        });

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM