2014-09-28 63 views

回答

0

使用一個Intent分享圖像在Facebook中。

Intent sharingIntent = new Intent(Intent.ACTION_SEND); 
Uri screenshotUri = null; 
if(imageUri!=null){ 
    screenshotUri = Uri.parse(imageUri); 
    sharingIntent.setType("image/jpeg"); 
    sharingIntent.putExtra(Intent.EXTRA_STREAM, screenshotUri); 
} 
startActivity(Intent.createChooser(sharingIntent, "Share image using...")); 

確保您的圖像Uri不爲空。這將啓動一個意圖,將顯示您可以共享圖像的所有應用程序。其中,Facebook。

+0

您確定此代碼仍然有效嗎?由於Facebook不再支持intent.putExtra。你可能想閱讀[this](https://stackoverflow.com/questions/7545254/android-and-facebook-share-intent)。 – 2014-09-28 14:41:27

+0

我剛剛測試了我的代碼,併成功發佈了它。 Facebook忽略EXTRA_SUBJECT或EXTRA_TEXT字段,而不是Intent.EXTRA_STREAM字段。 – joao2fast4u 2014-09-28 14:49:02

+0

這是一個好消息。感謝您的分享 – 2014-09-28 14:50:18

相關問題