Android: do not get the correct text when sharing with embedded applications

I used the following code.

Intent share = new Intent(android.content.Intent.ACTION_SEND); share.setType("text/plain"); share.putExtra(Intent.EXTRA_SUBJECT, subject); share.putExtra( Intent.EXTRA_TEXT, "i have just visited http://www.google.com"); startActivity(Intent.createChooser(share, "Share Sydneyho! with your friends via")); 

When I select gmail , it shows what is written in Intent.EXTRA_TEXT , but when I select facebook its a completely different message, and I donโ€™t know where it comes from.

Please, help!

+6
source share
2 answers

You have similar entries in stackoverflow and come to this conclusion, we cannot pass text to

  share.putExtra(Intent.EXTRA_TEXT,"bla bla bla"); 

to make it visible on the facebook sharing page, but we need to pass the link to the website.

-1
source

I used the following code snippet for messaging with Action_Send in other applications.

 Intent sharingIntent = new Intent(Intent.ACTION_SEND); sharingIntent.setType("text/plain"); sharingIntent.putExtra("android.intent.extra.SUBJECT", ""); sharingIntent.putExtra("android.intent.extra.TEXT", "ABC"); startActivity(Intent.createChooser(sharingIntent, "Share using")); 

And it works fine on my device (Android 2.2). Conceptually, I donโ€™t know what distinguishes your code above. But the above code is great for me.

0
source

Source: https://habr.com/ru/post/908427/


All Articles