Facebook分享按钮导致facebook sdk崩溃

时间:2016-05-03 16:25:42

标签: android facebook listview share-button

我在@listview的eache项目中有一个分享按钮应用程序启动良好,但是当我按下Facebook sharebutton按钮时它会崩溃。

holder.button = (ShareButton) v.findViewById(R.id.btnOne);
holder.button.setOnClickListener(new View.OnClickListener() { 

@Override 
public void onClick( View v) {

    v.setTag(holder);

    Drawable mDrawable =  holder.imageview.getDrawable();
    Bitmap image = ((BitmapDrawable)mDrawable).getBitmap();

    SharePhoto photo = new SharePhoto.Builder().setBitmap(image)
   .build();

    SharePhotoContent content = new SharePhotoContent
          .Builder().addPhoto(photo).build();

    ShareApi.share(content, null);                                  
}       

});

这是logCat logCat

清单

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

    

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


    <activity
        android:name=".MainActivity"
        android:label="@string/app_name" >
        <intent-filter>
            <action android:name="android.intent.action.MAIN" />
            <category android:name="android.intent.category.LAUNCHER" />
        </intent-filter>
    </activity>

1 个答案:

答案 0 :(得分:0)

使用此代码段与Facebook分享内容:

private Context mContext;    

public void setupFacebookShareIntent() {

            ShareDialog shareDialog;

            FacebookSdk.sdkInitialize(mContext);
            shareDialog = new ShareDialog((Activity) mContext);

            ShareLinkContent linkContent = new ShareLinkContent.Builder()
                    .setContentTitle("YOUR TITLE")
                    .setContentDescription("YOUR DESCRIPTION")
                    .setContentUrl(Uri.parse("http://xxxx.com/"))
                    .setImageUrl(Uri.parse("http://xxxx.com/"))
                    .build();

            shareDialog.show(linkContent);
        }