2017-03-28 4 views
0

私のアプリからの曲を共有したい。私はGmailでか、それは解決できない空のファイルと残念にリソースを添付することができないエラーを示しxenderしかし、私はアプリいただきました!で曲を共有することができ、このコードに私は歌を共有したいが、それはエラーを表示する

//here collections.get(a).getpath() contains pathof file 

Uri uri = Uri.parse(collections.get(a).getpath()); 
       Intent share = new Intent(Intent.ACTION_SEND); 
       share.setType("audio/mp3"); 
       share.putExtra(Intent.EXTRA_STREAM, uri); 
       startActivity(Intent.createChooser(share, "Share Sound File")); 

を試してみました。

私はまた、誰もが、それはコードの下に使用してくださいあなたの

Intent share = new Intent(Intent.ACTION_SEND); 
share.setType("audio/*"); 
share.putExtra(Intent.EXTRA_STREAM,Uri.parse("file:///"+collections.get(a).getpath())); 
startActivity(Intent.createChooser(share, "Share Sound File")); 
+0

あなたのコードをデバッグしましたか? –

+1

uri ie collection.get(a).getpath() –

+0

logcatを投稿する –

答えて

0

と間違っているものを教えてもらえます

share.setType("audio/*"); 

を試してみました。

File file=new File("Enter audio path"); // get your file path here 
Uri uri = Uri.parse("file://"+file.getAbsolutePath()); // generate Uri of file 

    Intent share = new Intent(Intent.ACTION_SEND); 
    share.setType("audio/*"); 
    share.putExtra(Intent.EXTRA_STREAM, uri); // put generated uri here 
    startActivity(Intent.createChooser(share, "Share Sound File")); // it will show dialog where you need to share audio file with different application 

これらの情報が役立ちます。

+0

私は "file:///"を使用していないので、私を助けたすべての人のおかげでエラーが発生しました – ravalrocks

0

を助けている場合、コード下記をご覧ください。このコード

関連する問題