Facebook SDK Sharing always close immidiately after open if use Mode.AUTOMATIC and Mode.NATIVE, FacebookException return NULL

it's working if I use Mode.FEED or Mode.WEB. but I need it to share via app if it is available. Anyone know why and how I'm able to use Mode.NATIVE or Mode.AUTOMATIC ?

Main Post:
I tried to add Facebook Sharing using Facebook SDK and somehow it's always closed immidiately and the FacebookException always null so I don't know why it's not working. I've follow steps on Facebook documentation like this:

add mavenCentral()
add Fb SDK library

add internet permission

<uses-permission android:name="android.permission.INTERNET"/>

add FacebookActivity

            android:label="@string/app_name" />

add MetaData

 <meta-data android:name="com.facebook.sdk.ApplicationId" android:value="@string/facebook_app_id"/>

add Provider

<provider android:authorities="com.facebook.app.FacebookContentProvider240590073210961"

all codes above except permission are inside Tag in Android Manifest

and then create CallbackManager:

    callbackManager = CallbackManager.Factory.create();

add ActivityResult

    protected void onActivityResult(final int requestCode, final int resultCode, final Intent data) {
        super.onActivityResult(requestCode, resultCode, data);
        callbackManager.onActivityResult(requestCode, resultCode, data);

call The ShareDialog:

ShareLinkContent content = new ShareLinkContent.Builder()
                ShareDialog shareDialog = new ShareDialog(MainActivity.this);
                shareDialog.registerCallback(callbackManager, new FacebookCallback<Sharer.Result>() {
                    public void onSuccess(Sharer.Result result) {


                    public void onCancel() {


                    public void onError(FacebookException error) {

                shareDialog.show(content, ShareDialog.Mode.AUTOMATIC);

but... nothing happen. in a device I noticed it's closed immidiately after open, in less than a second. I tried to debug but the FacebookException in onError are null I also have added my keyhash to my developer settings.

Facebook app is installed and working properly. even though it's not, it should open on browser, right ? What did I miss here ?

Thank you in advance!

1 answer