发布您的代码如何将图像上传到 Facebook。这是一个对我来说运行良好的示例代码,看看可能对你有帮助。在我的代码中没有创建任何相册墙照片。我的照片被上传到墙上。看看...
private void fbImageSubmit() {
if (facebook != null) {
if (facebook.isSessionValid()) {
try {
byte[] data = null;
// Bitmap bi = BitmapFactory.decodeFile(Constants.imgShare);
ByteArrayOutputStream baos = new ByteArrayOutputStream();
bmScreen.compress(Bitmap.CompressFormat.JPEG, 100, baos);
data = baos.toByteArray();
Bundle parameters = new Bundle();
parameters.putString("message", strmsg);
parameters.putString("method", "photos.upload");
parameters.putByteArray("picture", data);
facebook.request(null, parameters, "POST");
/*
* time = Calendar.getInstance().getTime().getHours() + ":"
* + Calendar.getInstance().getTime().getMinutes();
*/
currentTime = DateFormat.format("hh:mm", d.getTime());
currentDate = DateFormat.format("dd/MM/yyyy", d.getTime());
Cursor cursor = Constants.dbHelper
.GetDataFromImageName(Constants.enhancedImage
.getImagename());
if (cursor.getCount() > 0) {
Constants.dbHelper.updateData(currentDate.toString(),
currentTime.toString(), "Facebook", "Image");
} else {
Constants.dbHelper.insertData("true");
}
Toast.makeText(getApplicationContext(),
"Image uploaded successfully.", Toast.LENGTH_LONG)
.show();
} catch (Exception e) {
// TODO: handle exception
System.out.println(e.getMessage());
}
}
}
}
// bmscreen 是我的图像位图;希望对你有帮助。