我已尝试过很多代码在Facebook墙上发送图像,但它无效。 我正在使用此代码
Bitmap bitmap = BitmapFactory.decodeResource(shareDialogContext.getResources(),R.drawable.splash);
byte[] byetArray = convertBitmapToByteArray(shareDialogContext,bitmap);
params.putByteArray("picture",byetArray);
objFacebook.request(profileID + "me/photos", params, "POST");
public byte[] convertBitmapToByteArray(Context context, Bitmap bitmap) {
ByteArrayOutputStream buffer = new ByteArrayOutputStream(bitmap.getWidth() *
bitmap.getHeight());
bitmap.compress(CompressFormat.PNG, 100, buffer);
return buffer.toByteArray();
}
请建议任何有用的代码。
答案 0 :(得分:1)
hackbook示例是否完全符合您的要求?
Bundle params = new Bundle();
try {
params.putByteArray("photo",
Utility.scaleImage(getApplicationContext(), photoUri));
} catch (IOException e) {
e.printStackTrace();
}
params.putString("caption", "FbAPIs Sample App photo upload");
Utility.mAsyncRunner.request("me/photos", params, "POST",
new PhotoUploadListener(), null);
答案 1 :(得分:0)
这可能会对您有所帮助:
Bundle params = new Bundle();
try
{
params.putByteArray("photo",Utility.scaleImage(getApplicationContext(), photoUri));
}
catch (IOException e)
{
e.printStackTrace();
}
params.putString("caption", "Through My Android Application");
Utility.mAsyncRunner.request("me/photos", params, "POST",new PhotoUploadListener(), null);
可能重复:Android - Upload photo to Facebook with Facebook Android SDK