Android and Facebook share intent
The Facebook application does not handle either the
EXTRA_SUBJECT
orEXTRA_TEXT
fields.
Here is bug link: https://developers.facebook.com/bugs/332619626816423
Thanks @billynomates:
The thing is, if you put a URL in the
EXTRA_TEXT
field, it does
work. It's like they're intentionally stripping out any text.
Android Intent directly to Facebook sharing?
Try the following code, now the intent will open Facebook directly.
List<Intent> targetedShareIntents = new ArrayList<Intent>();
Intent facebookIntent = getShareIntent("facebook", "subject", "text_or_url");
// subject may not work, but if you have a url place it in text_or_url
if(facebookIntent != null)
targetedShareIntents.add(facebookIntent);
Intent chooser = Intent.createChooser(targetedShareIntents.remove(0), "Delen");
chooser.putExtra(Intent.EXTRA_INITIAL_INTENTS, targetedShareIntents.toArray(new Parcelable[]{}));
startActivity(chooser);
// To precisely get the facebook intent use the following code
private Intent getShareIntent(String type, String subject, String text)
{
boolean found = false;
Intent share = new Intent(android.content.Intent.ACTION_SEND);
share.setType("text/plain");
// gets the list of intents that can be loaded.
List<ResolveInfo> resInfo = getActivity().getPackageManager().queryIntentActivities(share, 0);
System.out.println("resinfo: " + resInfo);
if (!resInfo.isEmpty()){
for (ResolveInfo info : resInfo) {
if (info.activityInfo.packageName.toLowerCase().contains(type) ||
info.activityInfo.name.toLowerCase().contains(type) ) {
share.putExtra(Intent.EXTRA_SUBJECT, subject);
share.putExtra(Intent.EXTRA_TEXT, text);
share.setPackage(info.activityInfo.packageName);
found = true;
break;
}
}
if (!found)
return null;
return share;
}
return null;
}
Above code is extracted from this stackoverflow-post
Use Facebook sdk's ShareContent in share intent android
You need to add the Mime data type that the send intent is handling to get the appropriate activities returned:
share.setType("text/plain");
How to share text into facebook using default android sharing(intent)?
Try this...
Intent shareIntent = new Intent(Intent.ACTION_SEND);
shareIntent.setType("text/plain");
shareIntent.putExtra(Intent.EXTRA_SUBJECT, "Share this app");
String shareMessage = "https://play.google.com/store";
shareIntent.putExtra(Intent.EXTRA_TEXT, shareMessage);
startActivity(Intent.createChooser(shareIntent, "Choose the messenger to share this App"));
Related Topics
How to Develop a Soft Keyboard For Android
Can Not Find a View With Findviewbyid()
How to Lay Out Views in Relativelayout Programmatically
Open Application After Clicking on Notification
Android - Listview Get Item View by Position
Android Fragment Onclick Button Method
Default Firebaseapp Is Not Initialized
How to Dismiss the Dialog with Click on Outside of the Dialog
Receive Result from Dialogfragment
Android Youtube App Play Video Intent
Android Studio Keeps Refusing to Resolve Com.Android.Support:Appcompat-V7:29.0.1
How to Get Apk Signing Signature
How to Layout Text to Flow Around an Image
Android: Broadcast Receiver for Screen on and Screen Off
How to Modify Arrayadapter in Listview: Unsupportedoperationexception
Android: Coloring Part of a String Using Textview.Settext()
How to Add Stacktrace or Debug Option When Building Android Studio Project