Binil Surendran
Binil Surendran

Reputation: 2554

Android: Facebook sdk ShareLinkContent shareDialog Nullpointer exception

I am using facebook sdk jar file in eclipse to share link with content.

I create the app id in face book and add in manifest

Manifest

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

    <provider
        android:name="com.facebook.FacebookContentProvider"
        android:authorities="com.facebook.app.FacebookContentProviderxxxxxxxxx"
        android:exported="true" />

    <activity
        android:name="com.facebook.FacebookActivity"
        android:configChanges="keyboard|keyboardHidden|screenLayout|screenSize|orientation"
        android:label="@string/app_name"
        android:theme="@android:style/Theme.Translucent.NoTitleBar" />

But when i try to share in fb am getting Null pointer exception

java.lang.NullPointerExceptionat java.util.concurrent.ConcurrentHashMap.get(ConcurrentHashMap.java:883)

the code that am using for share is

 ShareLinkContent linkContent = new ShareLinkContent.Builder()
                        .setContentTitle("How to share content")
                        .setImageUrl(Uri.parse("https://www.numetriclabz.com/wp-content/uploads/2015/11/114.png"))
                        .setContentDescription(
                                "simple LinkedIn integration")
                        .setContentUrl(Uri.parse("https://www.numetriclabz.com/android-linkedin-integration-login-tutorial/"))
                        .build();


                shareDialog.show(linkContent); 

can anyone please tell me where am wrong

Upvotes: 2

Views: 359

Answers (1)

Rahul
Rahul

Reputation: 76

Sorry for late reply.
Please try this

in oncreate method before setContentView(R.layout.home);

FacebookSdk.sdkInitialize(mContext);

in on create method

ShareDialog shareDialog = new ShareDialog(getApplicationContext()); 

Upvotes: 1

Related Questions