facebook共享图像未通过android应用程序在facebook上显示
我是facebook整合的新手,我已经为此工作了几天,我相信我能够解决这个问题。我的问题是,我为共享对话框附加的图像没有显示在facebook上 这是我的代码:facebook共享图像未通过android应用程序在facebook上显示,android,facebook,Android,Facebook,我是facebook整合的新手,我已经为此工作了几天,我相信我能够解决这个问题。我的问题是,我为共享对话框附加的图像没有显示在facebook上 这是我的代码: public class ViewPagerAdapter extends PagerAdapter { Context context; String[] rank; String[] country; String[] population; int[] bookCover; LayoutInflater inflater;
public class ViewPagerAdapter extends PagerAdapter {
Context context;
String[] rank;
String[] country;
String[] population;
int[] bookCover;
LayoutInflater inflater;
@凌驾
公共对象实例化项(视图组容器,最终int位置){
使用提要对话框或提要图形API,您无法在
图片中传递图像数据。因此,您应该提供url而不是数据
这只是一个技巧-你可以先使用/photos
上传一张图片,在那里你可以使用图像数据,然后你可以使用这个图像url到提要中
快来帮忙,祝你好运
final PdfHandler pdf = new PdfHandler(context);
final int pdfPos = position;
inflater = (LayoutInflater) context.getSystemService(Context.LAYOUT_INFLATER_SERVICE);
View itemView = inflater.inflate(R.layout.viewpager_item, container, false);
ImageView imgflag = (ImageView) itemView.findViewById(R.id.flag);
// Capture position and set to the ImageView
//imgflag.setScaleType(ScaleType.FIT_XY);
imgflag.setImageResource(bookCover[position]);
// Add viewpager_item.xml to ViefeewPager
((ViewPager) container).addView(itemView);
imgflag.setOnClickListener(new OnClickListener() {
@Override
public void onClick(View v) {
int data = bookCover[position];
shareImage(data);
}
});
return itemView;
}
public void shareImage(int data) {
Bundle params = new Bundle();
params.putString("name", "Facebook SDK for Android");
params.putString("caption", "Build great social apps and get more installs.");
params.putString("description", "The Facebook SDK for Android makes it easier and faster to develop Facebook integrated Android apps.");
params.putString("link", "https://developers.facebook.com/android");
params.putInt("picture", data );
WebDialog feedDialog = (
new WebDialog.FeedDialogBuilder(context,
Session.getActiveSession(),
params))
.setOnCompleteListener(new OnCompleteListener() {
@Override
public void onComplete(Bundle values,
FacebookException error) {
if (error == null) {
// When the story is posted, echo the success
// and the post Id.
final String postId = values.getString("post_id");
if (postId != null) {
Toast.makeText(context,
"Posted story, id: "+postId,
Toast.LENGTH_SHORT).show();
} else {
// User clicked the Cancel button
Toast.makeText(context,
"Publish cancelled",
Toast.LENGTH_SHORT).show();
}
} else if (error instanceof FacebookOperationCanceledException) {
// User clicked the "x" button
Toast.makeText(context,
"Publish cancelled",
Toast.LENGTH_SHORT).show();
} else {
// Generic, ex: network error
Toast.makeText(context,
"Error posting story",
Toast.LENGTH_SHORT).show();
}
}
})
.build();
feedDialog.show();
}