现在我正在开发Android应用程序。在我的应用程序中,我必须从我的画廊提交图像到facebook.I使用以下代码。
if (item == 1) {
Intent intent = new Intent();
intent.setType("image/*");
intent.setAction(Intent.ACTION_GET_CONTENT);
startActivityForResult(Intent.createChooser(intent, "Complete action using"), PICK_FROM_FILE);
}
protected void onActivityResult(int requestCode, int resultCode, Intent data)
{
if (resultCode != RESULT_OK) return;
Bitmap bitmap = null;
if (requestCode == PICK_FROM_FILE) {
mImageCaptureUri = data.getData();
mPath = getRealPathFromURI(mImageCaptureUri); //from Gallery
if (mPath == null){
mPath = mImageCaptureUri.getPath(); //from File Manager
}
if (mPath != null) {
System.out.println("mpath is not null"+mPath);
bitmap = BitmapFactory.decodeFile(mPath);
}
}
}
private void postToFacebook(String desc){
AsyncFacebookRunner mAsyncFbRunner = new AsyncFacebookRunner(mFacebook);
Bundle params = new Bundle();
try {
params.putByteArray("photo",
Utility.scaleImage(getApplicationContext(),mImageCaptureUri));
} catch (IOException e) {
// TODO Auto-generated catch block
e.printStackTrace();
}
params.putString("caption", desc);
mAsyncFbRunner.request("me/photos", params, "POST",
new PhotoUploadListener());
}
它在emulater中工作正常,但在真实的设备图像中没有发布。但没有崩溃。请帮助我的朋友
答案 0 :(得分:1)
首先查看你的清单,这可能会对你有帮助。
android.permission.MANAGE_ACCOUNTS