Androidアプリからキャプション付きの画像を共有したい。どうすればできますか?
Intent.ACTION_SEND を使用して、ステータスまたは写真を Facebook にアップロードしています
完全なソースコードを使用して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();
}
}
public void share(View v) {
//facebook.dialog(this, "feed", new PostDialogListener());
Bundle parameters = new Bundle();
parameters.putString("message", category_item_name_desc.getText().toString());
parameters.putString("picture", categoryItemsModel.getImageUrl());
parameters.putString("caption", txtDescription_desc.getText().toString());
facebook.request("/me/feed", parameters, "POST");
try {
facebook.request("/me/feed", parameters, "POST");
System.out.println("**********************POST**********************************");
} catch (FileNotFoundException e) {
// TODO Auto-generated catch block
e.printStackTrace();
} catch (MalformedURLException e) {
// TODO Auto-generated catch block
e.printStackTrace();
} catch (IOException e) {
// TODO Auto-generated catch block
e.printStackTrace();
}
}