1

I have some problem with below code. This code is working for email, message, Twitter (for sending the text) but not for Facebook. Why?

Intent i=new Intent(android.content.Intent.ACTION_SEND);
i.setType("text/plain");
i.putExtra(android.content.Intent.EXTRA_SUBJECT,"ScribeAir");
i.putExtra(android.content.Intent.EXTRA_TEXT, "ScribeAir has some cool features. Just use it...");
startActivity(Intent.createChooser(i,"Share"));
Peter O.
  • 32,158
  • 14
  • 82
  • 96
Jyosna
  • 4,436
  • 13
  • 60
  • 93

4 Answers4

0

This is not working for Facebook because Facebook can share only a link via ACTION_SEND. if you want to send Text As well as you mentioned:

Firstly you have to get the list of installed application that support ACTION_SEND.

Then build a dialog

  Intent sharingIntent = new Intent(android.content.Intent.ACTION_SEND);
    sharingIntent.setType("text/plain");
    List activities = getPackageManager().queryIntentActivities(sharingIntent,0);

After the activities now build a dialog to show activities .then get the intent for Facebook and share it with Facebook API all other to be handled by itself but please pass the class name for other activities.

Intent sharingIntent = new Intent(android.content.Intent.ACTION_SEND); 
    sharingIntent.setClassName(,);
    sharingIntent.setType("text/plain");
    sharingIntent.putExtra(android.content.Intent.EXTRA_SUBJECT,"hello");
    sharingIntent.putExtra(android.content.Intent.EXTRA_TEXT, "facebook"); 
Michele La Ferla
  • 6,775
  • 11
  • 53
  • 79
  • 10
    I understood NOTHING from your post. – Radu Apr 26 '13 at 11:53
  • 3
    What he says, was that you can't send text to share with faebook directly across the intent, you should use de API provided by facebook to do it... If you like to do it, you have to get the activities of the intent action send, then, get the event if facebook is selected, and, if facebook is selected you should use the Facebook API to share... – Leonardo Sapuy May 02 '13 at 17:26
0
Intent sharing = new Intent(android.content.Intent.ACTION_SEND); 
    sharing.setClassName(,);
    sharing.setType("text/plain");
    sharing.putExtra(android.content.Intent.EXTRA_SUBJECT,"hello");
    sharing.putExtra(android.content.Intent.EXTRA_TEXT, "yahoomail");
Michele La Ferla
  • 6,775
  • 11
  • 53
  • 79
0

Answering to question which is asked long long time ago..

As of i know, Facebook does not allow the Pre-populating of text through Intent unlike in the Twitter / Email. It by Facebook Default. But with the help of Facebook SDK, we can able to share text in the form of link.

Refer Facebook SDK sharing Docs

Swaminathan V
  • 4,663
  • 2
  • 22
  • 32
-7

try this:

i.setType("message/rfc822");
Vineet Shukla
  • 23,865
  • 10
  • 55
  • 63
  • By using above setType() now i can only send text through email not even message or twitter or facebook also. – Jyosna Aug 16 '11 at 10:31