0

我在@listview 应用程序的每个项目中都有一个共享按钮,它可以很好地启动,但是当我按下 Facebook 共享按钮按钮时它会崩溃。

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>
4

1 回答 1

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);
        }
于 2016-05-03T19:12:45.020 回答