简体   繁体   English

Android Facebook SDK共享对话框为空

[英]Android facebook sdk share dialog empty

I'm using the android facebook sdk in my app, expecially the ShareDialog (after I click on a button). 我在我的应用程序中使用android facebook sdk,尤其是ShareDialog(单击按钮后)。 It works all great, the only problem is that the Post dialog appears empty, without the content I set in the code. 一切正常,唯一的问题是“发布”对话框显示为空,而没有我在代码中设置的内容。 Note that I'm using a ListFragment, that's why My class extends ArrayAdapter and I'm not in an activity. 请注意,我使用的是ListFragment,这就是为什么我的类扩展ArrayAdapter而不参加活动的原因。 Here is my code: 这是我的代码:

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;
}

i am getting same problem with Facebook latest sdk, i have resolve using set ContentUri like following. 我在使用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);
            }

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM