我正在使用来自 hackbook 的代码进行 android 教程,并且我已经能够将图片上传到我的墙上。我现在想要的是上传一张从我的相机拍摄的照片,并将其上传到某个群组的某个相册中。
我认为需要修改的部分代码是这样的:
/*
* Source Tag: upload_photo You can upload a photo from the media
* gallery or from a remote server How to upload photo:
* https://developers.facebook.com/blog/post/498/
*/
case 3: {
if (!Utility.mFacebook.isSessionValid()) {
Util.showAlert(this, "Warning", "You must first log in.");
} else {
dialog = ProgressDialog.show(Hackbook.this, "",
getString(R.string.please_wait), true, true);
new AlertDialog.Builder(this)
.setTitle(R.string.gallery_remote_title)
.setMessage(R.string.gallery_remote_msg)
.setPositiveButton(R.string.gallery_button,
new DialogInterface.OnClickListener() {
@Override
public void onClick(DialogInterface dialog, int which) {
Intent intent = new Intent(Intent.ACTION_PICK,
(MediaStore.Images.Media.EXTERNAL_CONTENT_URI));
startActivityForResult(intent,
PICK_EXISTING_PHOTO_RESULT_CODE);
}
})
.setNegativeButton(R.string.remote_button,
new DialogInterface.OnClickListener() {
@Override
public void onClick(DialogInterface dialog, int which) {
/*
* Source tag: upload_photo_tag
*/
Bundle params = new Bundle();
params.putString("url",
"http://www.facebook.com/images/devsite/iphone_connect_btn.jpg");
params.putString("caption",
"FbAPIs Sample App photo upload");
Utility.mAsyncRunner.request("me/photos", params,
"POST", new PhotoUploadListener(), null);
}
}).setOnCancelListener(new DialogInterface.OnCancelListener() {
@Override
public void onCancel(DialogInterface d) {
dialog.dismiss();
}
}).show();
}
break;
}
那么你能帮我解决这个问题吗:1)有可能吗?或者我必须先把照片拍下来,把它存放在某个地方,然后再找到它。我想避免这种情况(我的意思是来自用户——如果它可以通过编程方式完成,那么就没有问题了)。2)我需要改变哪些论点?