我正在开发一款具有社交功能的Android应用程序 我希望有一个功能,他们可以将多张照片上传到帖子中的私人组。
像这样的图像: http://i.stack.imgur.com/hMIBg.png
我已经为fb做了一些开放图和android api的研究。我使用RequestBatch来分隔不同的图片,但facebook没有将它们合并为一个帖子
我也使用WebDialog发布帖子,但我找不到让FeedDialog指向组墙的方法。
我在Google上做了很多调查,但无法找出任何工作解决方案。
如果有人知道如何做或给我一些例子,我将不胜感激。提前谢谢。
////////////////////第一种方式:向fb发送批量请求,我认为它会将它们合并到一个帖子中但不是......
ArrayList<String> list = new ArrayList();
list.add("http://example.url:8000/uploads/images1.jpg");
list.add("http://example.url:8000/uploads/images2.jpg");
list.add("http://example.url:8000/uploads/images3.jpg");
int index = 0;
RequestBatch reqBatch = new RequestBatch();
do {
Bundle postParams = new Bundle();
postParams.putString("picture", list.get(index).toString());
postParams.putString("message", "message");
Request request = new Request(Session.getActiveSession(),"group_id/feed", postParams, HttpMethod.POST);
request.setCallback( new Request.Callback() {
@Override
public void onCompleted(Response response) {
Log.d(TAG, ""+response);
}
});
reqBatch.add(request);
index++;
}while(list.size()>index);
reqBatch.executeAsync();
/////////////////////////////////////////////// //////////////////////////////// //第二种方式:获取webDialog
Bundle params = new Bundle();
params.putString("name", "name");
params.putString("caption", "caption");
params.putString("description", "TEST");
params.putString("link", "http://image.url/image.jpg");
params.putString("to", "group_id"); // how to change to group wall???? and how to set 2+ photos???
WebDialog feedDialog = (
new WebDialog.FeedDialogBuilder(this,
Session.getActiveSession(),params)).setOnCompleteListener(new OnCompleteListener() {
@Override
public void onComplete(Bundle values, FacebookException error) {
// TODO Auto-generated method stub
Log.d(TAG, values.toString());
}
})
.build();
feedDialog.show();
答案 0 :(得分:0)
您可以使用Facebook应用分享多个图片。
protected void share(String nameApp, String imagePath, String text) {
// TODO Auto-generated method stub
try {
List<Intent> targetedShareIntents = new ArrayList<Intent>();
Intent share = new Intent(android.content.Intent.ACTION_SEND_MULTIPLE);
share.setType("image/jpeg");
List<ResolveInfo> resInfo = getActivity().getPackageManager()
.queryIntentActivities(share, 0);
if (!resInfo.isEmpty()) {
for (ResolveInfo info : resInfo) {
Intent targetedShare = new Intent(
android.content.Intent.ACTION_SEND_MULTIPLE);
targetedShare.setType("image/png"); // put here your mime
// type
if (info.activityInfo.packageName.toLowerCase().contains(
nameApp)
|| info.activityInfo.name.toLowerCase().contains(
nameApp)) {
targetedShare.putExtra(Intent.EXTRA_SUBJECT, text);
targetedShare.putExtra(Intent.EXTRA_TEXT, text);
ArrayList<Uri> files = new ArrayList<Uri>();
for(int j= 0;j<caminhos.size();j++){
if(!caminhos.get(j).isEmpty()){
File file = new File(caminhos.get(j));
Uri uri = Uri.fromFile(file);
files.add(uri);
}
}
targetedShare.putParcelableArrayListExtra(Intent.EXTRA_STREAM,
files);
targetedShare.setPackage(info.activityInfo.packageName);
targetedShareIntents.add(targetedShare);
}
}
Intent chooserIntent = Intent.createChooser(
targetedShareIntents.remove(0), "Select app to share");
chooserIntent.putExtra(Intent.EXTRA_INITIAL_INTENTS,
targetedShareIntents.toArray(new Parcelable[] {}));
startActivity(chooserIntent);
}
} catch (Exception e) {
}
}