我想通过我的 Android 应用程序分享带有字幕的图像。 我该怎么做?
我正在使用 Intent.ACTION_SEND 将状态或照片上传到 Facebook
最佳答案
请参阅 this 中的代码将 facebook 完全集成到具有完整源代码的 android 应用程序的链接,并编写下面的方法而不是 postToWall(String message)
public void postPhotoToWall() {
Bitmap bmp = BitmapFactory.decodeResource(getResources(), R.drawable.ic_launcher);
ByteArrayOutputStream stream = new ByteArrayOutputStream();
bmp.compress(Bitmap.CompressFormat.PNG, 100, stream);
final byte[] data = stream.toByteArray();
Bundle parameters = new Bundle();
parameters.putString("message", "Message");
parameters.putByteArray("picture", data);
parameters.putString("caption", "test");
try {
facebook.request("me/photos");
String response = facebook.request("me/photos", parameters, "POST");
Log.d("Tests", "got response: " + response);
if (response == null || response.equals("") || response.equals("false")) {
showToast("Blank response.");
} else {
showToast("Photo posted to your facebook wall!");
}
} catch (Exception e) {
showToast("Failed to post to wall!");
e.printStackTrace();
}
}
关于android - 我如何从 Android 应用程序与文本共享图像到 Facebook?我正在使用 Intent.ACTION_SEND 将状态或照片上传到 Facebook,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/14274351/