Facebook Dialog in android Not suitable

I am developing an Android application where I use the Android SDK for Android.

I want to use the Facebook sharing dialog:

ShareLinkContent content = new ShareLinkContent.Builder()
                .setContentUrl(Uri.parse("https://developers.facebook.com"))
                .build();

When I launch the application, nothing happens, the dialog does not appear - there are no errors.

Does anyone help?

+4
source share
1 answer

Initialize first

FacebookSdk.sdkInitialize(getApplicationContext());
callbackManager = CallbackManager.Factory.create();
shareDialog = new ShareDialog(this);

Than show

if (ShareDialog.canShow(ShareLinkContent.class)) {
ShareLinkContent linkContent = new ShareLinkContent.Builder()
        .setContentTitle("Hello Facebook")
        .setContentDescription(
                "The 'Hello Facebook' sample  showcases simple Facebook integration")
        .setContentUrl(Uri.parse("http://developers.facebook.com/android"))
        .build();

shareDialog.show(linkContent);
}

Finally call it.

@Override
protected void onActivityResult(final int requestCode, final int resultCode, final Intent data) {
    super.onActivityResult(requestCode, resultCode, data);
    callbackManager.onActivityResult(requestCode, resultCode, data);
}
+5
source

All Articles