Question

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.

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. I only saw dropbox, bluetooth, drive, email, evernote, gmail, onedrive. Although I already logged in to Facebook, G+ and Twitter on my device.

Any one has some idea?

Thanks in advance.

Was it helpful?

Solution

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"));
            }
        });
Licensed under: CC-BY-SA with attribution
Not affiliated with StackOverflow
scroll top