Android facebook sdk 共享对话框为空

Android facebook sdk share dialog empty

我在我的应用程序中使用 android facebook sdk,特别是 ShareDialog(在我单击按钮之后)。一切都很好,唯一的问题是 Post 对话框显示为空,没有我在代码中设置的内容。请注意,我使用的是 ListFragment,这就是我的 class 扩展 ArrayAdapter 而我不在 activity 中的原因。这是我的代码:

public class CustomAdapter extends ArrayAdapter<ModelVoted> {

String [] result;
private final Activity context;
private final List<ModelVoted> stateList;
ShareDialog shareDialog;


public CustomAdapter(Activity context, List<ModelVoted> listS, String[] list) { 
    super(context, R.layout.list_item, listS);
    result=list;
    this.context = context;
    this.stateList = listS; 
}




@Override
public int getCount(){
    return result.length;
}

@Override
public long getItemId(int position){
    return position;
}



@Override
public View getView(final int position, View convertView, ViewGroup parent) {

Holder holder = null; //final Holder holder=new Holder();
    if(convertView==null) {
        LayoutInflater inflater = context.getLayoutInflater();
        convertView = inflater.inflate(R.layout.list_item, null, false);
        holder=new Holder();


        holder.shareButton= (ImageButton)convertView.findViewById(R.id.imageButton);


        holder.shareButton.setOnClickListener(new OnClickListener() { 
            @Override
            public void onClick(View v) {
                shareDialog = new ShareDialog(context);
                if (ShareDialog.canShow(ShareLinkContent.class)) {
                    ShareLinkContent linkContent = new ShareLinkContent.Builder()
                            .setContentTitle("Hi! I just used the app! ")
                            .setContentDescription(
                                    "Hi! This is my post: " + result[position])
                            .build();

                    shareDialog.show(linkContent);
                }
            }
        });





    }else{
        holder = (Holder) convertView.getTag();
    }



    return convertView;
}

我在使用 Facebook 最新的 sdk 时遇到了同样的问题,我已经解决了使用 set ContentUri 的问题,如下所示。

ShareDialog shareDialog = new ShareDialog(baseActivity);
            if (ShareDialog.canShow(ShareLinkContent.class)) {
                ShareLinkContent linkContent = new ShareLinkContent.Builder()
                        .setContentTitle("Hi! I just used the app! ")
                        .setContentDescription(
                                "Hi! This is my post: " + result[position])
                        .setContentUrl(Uri.parse("http://www.*****.com/"))
                        .build();
                shareDialog.show(linkContent);
            }