arash moeen arash moeen - 1 year ago 68
Java Question

Facebook android shareDialog closes after opening

Following THIS I'm using facebook sdk in my android application and for test I've added below code to my MainActivity:

CallbackManager callbackManager;
ShareDialog shareDialog;

protected void onCreate(Bundle savedInstanceState) {

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

if (ShareDialog.canShow(ShareLinkContent.class)) {
ShareLinkContent linkContent = new ShareLinkContent.Builder()
.setContentTitle("Hello Facebook")
"The 'Hello Facebook' sample showcases simple Facebook integration")

and I've added the following steps in my manifest:

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

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

<provider android:authorities=""
android:exported="true" />

<activity android:name="com.facebook.FacebookActivity"
android:label="@string/app_name" />

and when I test the shareDialog pops up and suddenly it closes itself.

Answer Source

You need to make your app "Public".

Go to the "Status and Review" section in your app settings, and turn on the option "Do you want to make this app and all its live features available to the general public?"

Recommended from our users: Dynamic Network Monitoring from WhatsUp Gold from IPSwitch. Free Download