i am using the facebook sdk 3.5 to implement sharing dialog i can now successfully show a share dialog with link app name and description it now goes to facebook ...however when i press the share button it posts a message on toast with:
something went wrong please try again
Here is how i use share dialog:
FacebookDialog.ShareDialogBuilder shareDialogBuilder = new FacebookDialog.ShareDialogBuilder(MyClass.this)
.setApplicationName("app name")
.setName("Name")
.setLink("my link");
if (shareDialogBuilder.canPresent()) {
shareDialogBuilder.build().present();
} else {
Log.v("", "CAN_PRESENT() failed");
}
i read some related issues and checked on my link but it is working properly and called properly.. is there any way that i can log the error? what other issues might be causing this issue?
thank you.
Related
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.
I am sharing the app on facebook. Once i do that, the facebook post doesn't take me back to my activity. Instead displays a toast saying "your post is shared" and loops back to the share page.
Is there anything i am doing wrong?
if (FacebookDialog.canPresentShareDialog(this,
FacebookDialog.ShareDialogFeature.SHARE_DIALOG)) {
FacebookDialog shareDialog = new FacebookDialog.ShareDialogBuilder(this)
.setLink(SharedVariables.url)
.setName("Name")
.setCaption("Caption")
.setDescription("Description")
.build();
shareDialog.present();
SharedVariables.uiHelper.trackPendingDialogCall(shareDialog.present());
}
If you have your activity marked android:noHistory="true" in your AndroidManifest.xml, it will not return. Please check for this.
There is also a duplicate of present() call in the code:
shareDialog.present();
SharedVariables.uiHelper.trackPendingDialogCall(shareDialog.present());
Try removing the first one - it should not be needed.
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
My requirement is to share on Social networking sites. So, I have already done with Facebook and Twitter. But I am stuck with Google+. I have the following code to share on Google+, but the app forcecloses when I start activity. This occurs only when the Google+ app isn't installed on device already. I know this sharing intent requires the Google+ already installed to start the activity.
Now what I need to do is at least to inform the user that the google+ sharing requires already installed google+ app through dialog or toast instead of getting force closed (If possible by clicking on ok on the dialog should redirect to the google+ on google play). If the google+ app is installed already it goes as usual.
Intent shareIntent = ShareCompat.IntentBuilder.from(this)
.setText("Hello there! This is a pic of the lazy cat")
.setType("image/jpeg")
.setStream(Uri.parse(path))
.getIntent()
.setPackage("com.google.android.apps.plus");
startActivity(shareIntent);
Any help is appreciated. Thanks in advance.
UPDATE
The answer below is outdated. You can now check if the Google+ app is installed through the Google Play Services library (available through the Android SDK). See here for information how to add it to your project.
Example:
int errorCode = GooglePlusUtil.checkGooglePlusApp(mContext);
if (errorCode != GooglePlusUtil.SUCCESS) {
//Google+ is either not present or another error occured, show the error dialog
GooglePlusUtil.getErrorDialog(errorCode, this, 0).show();
}
else{
//Your Google+ related code here
}
OLD ANSWER
You can create some sort of check to see if the Google+ app is installed:
public void loadGooglePlus()
{
if(isGooglePlusInstalled())
{
Intent shareIntent = ShareCompat.IntentBuilder.from(this)
.setText("Hello there! This is a pic of the lazy cat")
.setType("image/jpeg")
.setStream(Uri.parse(path))
.getIntent()
.setPackage("com.google.android.apps.plus");
startActivity(shareIntent);
}
else{
//Notify user
}
}
public boolean isGooglePlusInstalled()
{
try
{
getPackageManager().getApplicationInfo("com.google.android.apps.plus", 0 );
return true;
}
catch(PackageManager.NameNotFoundException e)
{
return false;
}
}
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.