Share to Facebook in android (like twitter) - android

As anyone who's tried to share to Facebook via Android knows, the Facebook team has decided to disregard the protocol for sharing and ignores the text provided in the share intent (see: Share Text on Facebook from Android App via ACTION_SEND)
However, it appears that the twitter app has figured out how to circumvent this. When you're looking at a tweet:
You can click the share icon below the tweet and it brings up the normal share dialog with a list of apps, including Facebook:
If you click on Facebook, you get this view:
Which looks perfect, and clearly twitter is sending more than just a link that other answers seem to propose. Furthermore, if you share to messaging:
You can see that the text is properly added and there are no issues. How did twitter get this to work?

If you're asking how you can include pre-fill text when sharing a link to Facebook from another app, this is actually directly against Facebook's policy -
"Ensure that all content in the user message parameter is entered by the user. Don’t pre-fill. This includes posts, messages, comments, and captions." (https://developers.facebook.com/policy/)

what i did to over come the problem is little nasty but useful,
copy the text that want to be shared in clip board and
toast message "paste text",
Copying to clipboard
#SuppressLint("NewApi")
private void copyToClipBoard(String data)
{
int sdk = android.os.Build.VERSION.SDK_INT;
if(sdk < android.os.Build.VERSION_CODES.HONEYCOMB)
{
android.text.ClipboardManager clipboard = (android.text.ClipboardManager) getActivity().getSystemService(Context.CLIPBOARD_SERVICE);
clipboard.setText(data);
Toast.makeText(context,"Paste text", Toast.LENGTH_SHORT).show();
}
else
{
android.content.ClipboardManager clipboard = (android.content.ClipboardManager) getActivity().getSystemService(Context.CLIPBOARD_SERVICE);
android.content.ClipData clip = android.content.ClipData.newPlainText(type,data);
clipboard.setPrimaryClip(clip);
Toast.makeText(context, "Paste text", Toast.LENGTH_SHORT).show();
}
}

Just to close out this question, I believe the way it works for Twitter in the example is based on the meta data available in the url provided. This is a good starting point: https://developers.facebook.com/docs/sharing/best-practices#tags

Related

firebase dynamic link preview link not working with facebook messenger

Created firebase dynamic short link will not preview correctly in facebook messenger.
It puts up the message and link as expected and shows a preview image with url.
The url included in the message is working but not the url if I click on the preview.
The url should be : https://q3zbm.app.goo.gl/8f7b
but the preview link becomes https://q3zbm.app.goo.gl/s?socialDescription=Welcome&socialImageUrl=http://andreasandersson.nu/images/awesome-photo.jpg&socialTitle=Gooo
I was able to reproduce this in a very small program
private void generate() {
DynamicLink.SocialMetaTagParameters.Builder params = new DynamicLink.SocialMetaTagParameters.Builder();
params.setImageUrl(Uri.parse("http://andreasandersson.nu/images/awesome-photo.jpg"));
params.setDescription("Welcome");
params.setTitle("Gooo");
FirebaseDynamicLinks.getInstance()
.createDynamicLink()
.setLink(Uri.parse("http://andreasandersson.nu"))
.setDynamicLinkDomain("q3zbm.app.goo.gl")
.setIosParameters(new DynamicLink.IosParameters.Builder("ios.app.example").build())
.setAndroidParameters(new DynamicLink.AndroidParameters.Builder().build())
//.setSocialMetaTagParameters(params.build())
.buildShortDynamicLink(SHORT)
.addOnCompleteListener(new OnCompleteListener<ShortDynamicLink>() {
#Override
public void onComplete(#NonNull Task<ShortDynamicLink> task) {
if (task.isSuccessful()) {
Uri shortLink = task.getResult().getShortLink();
Uri flowchartLink = task.getResult().getPreviewLink();
Intent shareIntent = new Intent();
shareIntent.setAction(Intent.ACTION_SEND);
shareIntent.setFlags(Intent.FLAG_ACTIVITY_NEW_TASK);
shareIntent.putExtra(Intent.EXTRA_TEXT, "check this:" + shortLink.toString());
shareIntent.setType("text/plain");
startActivity(Intent.createChooser(shareIntent, "share"));
}
}
});
}
I know that the app values are not correct but inputting correct ones gives no difference in the result.
Is this an error on the firebase dynamic link or is the problem with facebook messenger?
When doing the exact same thing from ios it is working as intended which should mean that this is a android related issue with the sharer?
Update: Thanks for contacting FIrebase support. This is an issue with Facebook that we already raised to them. As of now, we are yet to hear any updates from them, but once we do, we'll let you know.
I think that Facebook will not allow this because it would be in violation of their Fake news issue. The ability to change the image used when sharing links was removed and the Firebase meta info would allow you to circumvent this.
Update
After playing around with URL's it turns out I had a trailing "/" before "?" which was preventing the link working with Facebook. Using firebase links we can now set all meta info and provide custom thumbnails again.
I filed the similar question to Firebase support before. According to their support, it seems that it's on Facebook's side and they've filed a bug on Facebook. They also provided the bug tracker (https://business.facebook.com/direct-support/question/124595778189376/?force_full_site=0&business_id=191383518008569) but it appears I don't have necessary access to view the tracker, so I think this might also apply to you.

How to filter facebook share intent in android?

I have a share button. I share a message with some text and URL. It working well with whatsapp, Twitter and Gmail. But, in facebook share I'm able to share website link only. After, searching on web I have found ShareDialog class for facebook share.My question is how detect (ex: onClick() for facebook icon) when user click facebook icon on android default share dialog. Is it correct way ? or any other alternates is there?
My code :
public void shareApp() {
Intent sendIntent = new Intent();
String websiteLink = "https://www.manam.com";
String playStoreLink = "http://www.google.com";
String msg = "\nHey, found this cool & easy on-demand app.";
sendIntent.setAction(Intent.ACTION_SEND);
sendIntent.putExtra(Intent.EXTRA_SUBJECT, msg);
sendIntent.putExtra(Intent.EXTRA_TEXT,playStoreLink + msg);
sendIntent.setType("text/plain");
startActivity(Intent.createChooser(sendIntent, ""));
}
It's Facebook policy.
When you implement sharing, your app should not pre-fill any content to be shared. This is inconsistent with Facebook Platform Policy, see Facebook Platform Policy, 2.3.
I also don't see an option to detect click on facebook icon. And even if you can show your share dialog you wont be able to prefil any data

How to share Image to a specific user of Facebook messenger and Whatsapp

I already implemented how to share image in Facebook and WhatsApp messenger. But i wanted it in different way.
code
ActivityManager mActivityManager =(ActivityManager)c.getSystemService(Context.ACTIVITY_SERVICE);
if(Build.VERSION.SDK_INT > 20){
mPackageName = mActivityManager.getRunningAppProcesses().get(0).processName;
//Toast.makeText(this,mPackageName, Toast.LENGTH_LONG).show();
}
else{
mPackageName = mActivityManager.getRunningTasks(1).get(0).baseActivity.getPackageName();
}
Intent shareIntent = new Intent(Intent.ACTION_SEND);
shareIntent.setFlags(Intent.FLAG_ACTIVITY_NEW_TASK);
shareIntent.setType("image/jpg");
shareIntent.setPackage(mPackageName);
shareIntent.putExtra(Intent.EXTRA_STREAM, Uri.fromFile(dataFile));
Intent new_intent = Intent.createChooser(shareIntent, "Share via");
new_intent.setFlags(Intent.FLAG_ACTIVITY_NEW_TASK);
c.getApplicationContext().startActivity(new_intent);
It simply share image according to the package name. But the problem is it asks me to again choose the user from the friend list to share the image. But i want to share the image to the specific user from the beginning. I don't want it to redefine the user again.
Is there is a way to do it? in application like Facebook messenger and WhatsApp
This is a custom keyboard application where i am sharing the image to the application in where my keyboard is opened currently.
At least for Facebook Messenger; no, this is not possible. It is designed in such a way that you, as a developer, can notify the app that you want to share something. But the user will always have the final control to select the audience.
The best way to integrate with Messenger is to use the Send Button.
I believe this is also the case for Whatsapp, but I'm not 100% sure about that. Perhaps somebody else can confirm that.

does anyone know why facebook puts the wrong picture

I have this code for sharing an app on facebook but when i share it it puts right links but wrong picture of the app
Button bShare = (Button) findViewById(R.id.button7);
bShare.setOnClickListener(new View.OnClickListener() {
public void onClick(View v) {
final Intent intent = new Intent(Intent.ACTION_SEND);
intent.setType("text/plain");
intent.putExtra(Intent.EXTRA_TEXT, "https://play.google.com/store/apps/details?id=com.myglobaljournal.christmascarol");
startActivity(Intent.createChooser(intent, "Share with"));
You can use the Debug tool to check how facebook "sees" this url.
From the result you can see that there are no og meta tags defined and so facebook probably takes a random picture from the content.
Edit
Facebook uses the open graph meta tags to extract info which is then used to render the share stories on the facebook experience.
You can see an example in the archived version of the Open Graph protocol, the new version uses the tags there but it's too complicated to your needs.
The only question is: can you any control over the output of the google play store for your app?
My guess is that you can't, and if you look at other examples (such as instagram or opera mobile) the image also appears random.

Share via Google+..dialog complete action with shown

hi everybody i've a little problem..i'm trying to share a text using google plus app, but the lastest version give me a problem.
when i call with an intent "com.google.android.apps.plus", android display me this dialog
so if i choose the first one, text will be shared correctly, but the second one do nothing.
if the app is not intalled i redirect the user to the market, at g+ download page (this work fine)
if (v == plus) {
social(2);
targetedShareIntent.putExtra(
android.content.Intent.EXTRA_TEXT, user);
targetedShareIntent
.setPackage("com.google.android.apps.plus");
startActivity(targetedShareIntent);
}
"v" is a button and social check if app is installed
any sugestion?
both options open google+ application?
I suppose show two options because google+ app have two activities with category.LAUNCHER.... the app and the chat app
PSDT: sorry for my bad english!
I was able to get the G+ dialog to launch with the following code (after querying the package manager to make sure the app was actually installed and passing in the currentContext as a parameter):
Intent appIntent = new Intent(Intent.ACTION_SEND);
String shareText = "Share text goes here";
appIntent.setType("text/plain");
appIntent.putExtra(Intent.EXTRA_TEXT, shareText);
//Filters so only the G+ app will launch
appIntent.setPackage("com.google.android.apps.plus");
try {
currentContext.startActivity(appIntent);
} catch (android.content.ActivityNotFoundException e) {
Log.d(e.getMessage());
}
Drove me bananas figuring this out, so I figured I'd try to save someone else the hassle.

Categories

Resources