Reputation: 25
I'm using the android facebook sdk in my app, expecially the ShareDialog (after I click on a button). 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. 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;
}
Upvotes: 0
Views: 406
Reputation: 4705
i am getting same problem with Facebook latest sdk, i have resolve using set ContentUri like following.
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);
}
Upvotes: 1