I'm using share dialog to share a link onto the user's timeline but it's not working while the Facebook app is installed. It is functioning properly using the default browser (when the app is uninstalled). Note that FB login is working both with and without the FB app.
This is my code:
if(click_id==R.id.comboshare_fb) //Button click
{
loginButton.registerCallback(callbackManager, new FacebookCallback<LoginResult>() {
@Override
public void onSuccess(LoginResult loginResult) {
// App code
String userid = loginResult.getAccessToken().getUserId(); //Gets the userid.
Toast.makeText(getApplicationContext(), "Login Successful!", Toast.LENGTH_SHORT).show();
}
@Override
public void onCancel() {
}
@Override
public void onError(FacebookException error) {
}
}); //Login is working
shareDialog.registerCallback(callbackManager, new FacebookCallback<Sharer.Result>() {
@Override
public void onSuccess(Sharer.Result result) {
}
@Override
public void onCancel() {
Toast.makeText(getApplicationContext(), "Share Cancelled!", Toast.LENGTH_SHORT).show();
}
@Override
public void onError(FacebookException error) {
Log.d("Final Problem", "onError " + error);
}
});
ShareLinkContent linkContent = new ShareLinkContent.Builder()
.setQuote("I completed 3X Combo in Wordplay! :)")
.setContentUrl(Uri.parse("https://i2.wp.com/sbansite.files.wordpress.com/2018/07/yay-you-completed-3-combo-10.png?ssl=1&w=450"))
.build();
if(shareDialog.canShow(ShareLinkContent.class))
{
shareDialog.show(linkContent);
}}
The error that I'm getting from onError() of sharedialog is: D/Final Problem: onError Invalid long: "null"
Any help is welcome, thanks in advance.
P.S. My app is still in development mode at Facebook.
This is a bug introduced in the latest Facebook app.
Here's a link to the reported issue: https://developers.facebook.com/bugs/647119912303459/
If you want to add a workaround for your users who use this version of the app, you could add something like this in your error-callback:
@Override
public void onError(FacebookException error) {
if (error != null && error.getMessage().equals("null") {
// Don't use the app for sharing in case of null-error
shareDialog.show(linkContent, ShareDialog.Mode.WEB);
}
}
Sharing via the webview-share works