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

UPDATE:
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

<activity
            android:name="com.facebook.FacebookActivity"
            android:configChanges="keyboard|keyboardHidden|screenLayout|screenSize|orientation"
            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"
            android:name="com.facebook.FacebookContentProvider"
            android:exported="true"/>

all codes above except permission are inside Tag in Android Manifest

and then create CallbackManager:

    callbackManager = CallbackManager.Factory.create();

add ActivityResult

@Override
    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()
                        .setContentUrl(Uri.parse("https://developers.facebook.com"))
                        .build();
                ShareDialog shareDialog = new ShareDialog(MainActivity.this);
                shareDialog.registerCallback(callbackManager, new FacebookCallback<Sharer.Result>() {
                    @Override
                    public void onSuccess(Sharer.Result result) {

                    }

                    @Override
                    public void onCancel() {

                    }

                    @Override
                    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