我想從我的android應用程序共享帶有Caption的圖像。 我該怎麼做?我如何分享圖像與android應用程序到Facebook的文本?我正在使用Intent.ACTION_SEND將狀態或照片上傳到Facebook
我使用Intent.ACTION_SEND上傳狀態或照片至Facebook
我想從我的android應用程序共享帶有Caption的圖像。 我該怎麼做?我如何分享圖像與android應用程序到Facebook的文本?我正在使用Intent.ACTION_SEND將狀態或照片上傳到Facebook
我使用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();
}
}
它在facebook變量上出錯。 – user1969304
您使用的是Facebook sdk嗎? –
我不使用它。我想通過這段代碼分享從「App」到Facebook的圖片public void shareimage(){ \t \t \t Bitmap bi = BitmapFactory.decodeResource(this.getResources(),R.drawable.u); \t String path = Images.Media.insertImage(getContentResolver(),bi,「title」,null); \t Uri screenshotUri = Uri.parse(path); \t \t Intent share = new Intent(Intent.ACTION_SEND); \t share.setType(「image/png/jpeg」); \t share.putExtra(Intent.EXTRA_STREAM,Uri.parse(「file:///res/drawable/u.png」)); \t startActivity(Intent.createChooser(share,「Share Image2222」)); \t} – user1969304
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();
}
}
編輯你的問題,並更清楚地表明你想「分享」到Facebook,如果是這樣的話。 –
請看我的回答,它會解決你的問題。 –