2014-10-08 62 views
1

我有視頻網址,我從中解析到獲得uri。我試圖通過分享uri,但我沒有看到視頻被分享。分享視頻並保存視頻到圖庫

Uri uri = Uri.parse(url); 
Intent sharingIntent = new Intent(
        Intent.ACTION_SEND); 
sharingIntent.setType("video/*"); 
         sharingIntent.putExtra(Intent.EXTRA_STREAM,uri 
           ); 
startActivity(sharingIntent); 

我在這裏丟失了什麼,或者我應該將uri保存到外部存儲然後傳遞它?

此外我需要知道如何使用uri將圖片保存到圖庫。

+0

任何答案或建議? – user3722531 2014-10-08 18:30:25

+0

任何幫助,將不勝感激...... – user3722531 2014-10-09 14:12:31

回答

0

Intent.createChooser似乎缺少。請參閱代碼片段和鏈接。

Intent sharingIntent = new Intent(Intent.ACTION_SEND); 
Uri screenshotUri = Uri.parse(path); 

sharingIntent.setType("image/png"); 
sharingIntent.putExtra(Intent.EXTRA_STREAM, screenshotUri); 
startActivity(Intent.createChooser(sharingIntent, "Share image using")); 

鏈接:
http://sudarmuthu.com/blog/sharing-content-in-android-using-action_send-intent/

+0

感謝您的答案,我能夠看到發送選項列表,如Facebook,GMAIL等。當我選擇GMAIL,我看到電子郵件發送時沒有附加視頻。 – user3722531 2014-12-09 21:35:29

+0

我的意思是沒有你的答案我可以看到選項列表。我的主要問題是視頻沒有發送。你能幫助我嗎? – user3722531 2014-12-10 13:51:58

+0

我嘗試了類似的東西。它的工作 - 收到視頻文件作爲電子郵件附件。 您可能想要檢查視頻文件的大小。 另外,請看下面。 http://stackoverflow.com/questions/15965246/how-to-upload-video-to-youtube-in-android 該類型需要是: sharingIntent.setType(「video/*」); – 2014-12-10 22:57:40

2

使用本:

Intent intent = new Intent(Intent.ACTION_SEND); 
intent.setType("video/mp4"); 
intent.putExtra(Intent.EXTRA_STREAM, Uri.fromFile(new File(path))); 
startActivity(Intent.createChooser(intent, "share")); 

「路徑」 你的視頻傳似/sdcard/mVideo.mp4