Warning: file_get_contents(/data/phpspider/zhask/data//catemap/3/android/220.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
Android 如何在电报上共享音频_Android_Audio_Share_Telegram - Fatal编程技术网

Android 如何在电报上共享音频

Android 如何在电报上共享音频,android,audio,share,telegram,Android,Audio,Share,Telegram,我想做一个按钮来共享电报上的音频文件。 我只有电报的问题(在whatsapp上分享效果很好) 我的音频文件在原始文件夹中,我尝试使用.mp3、.wav和.m4a扩展名,但如果我尝试在电报上共享音频,我会收到“不支持的附件”的提示 这是我的分享方法: Intent share = new Intent(Intent.ACTION_SEND); share.setType("audio/m4a"); share.putExtra(Intent.EXTRA_STREAM, Uri.parse("and

我想做一个按钮来共享电报上的音频文件。 我只有电报的问题(在whatsapp上分享效果很好)

我的音频文件在原始文件夹中,我尝试使用.mp3、.wav和.m4a扩展名,但如果我尝试在电报上共享音频,我会收到“不支持的附件”的提示

这是我的分享方法:

Intent share = new Intent(Intent.ACTION_SEND);
share.setType("audio/m4a");
share.putExtra(Intent.EXTRA_STREAM, Uri.parse("android.resource://" + ctx.getPackageName() + "/" + R.raw.my_audio));
startActivity(Intent.createChooser(share, "Share on:"));

许多Android应用程序不会处理使用不当的
Android。资源://
方案。如果您想要更好的兼容性,请将音频写入一个文件并共享,或者使用
内容提供商(例如)通过
内容://
方案提供音频。

许多Android应用程序不会处理使用不当的
Android。资源://
方案。如果您想要更好的兼容性,请将音频写入一个文件并共享,或者使用
内容提供者(例如,)通过
内容://
方案提供音频。

使用“Uri.fromFile”,这对我很有效

                File file = new File(filePath);
                Uri uri = Uri.fromFile(file);
                Intent share = new Intent(Intent.ACTION_SEND);
                share.setType("audio/*");
                share.putExtra(Intent.EXTRA_STREAM, uri);
                startActivity(Intent.createChooser(share,
                        "به اشتراک گذاشتن فایل"));
使用“Uri.fromFile”,这对我很有用

                File file = new File(filePath);
                Uri uri = Uri.fromFile(file);
                Intent share = new Intent(Intent.ACTION_SEND);
                share.setType("audio/*");
                share.putExtra(Intent.EXTRA_STREAM, uri);
                startActivity(Intent.createChooser(share,
                        "به اشتراک گذاشتن فایل"));

如何使用ContentProvider?@genialFactory:您必须编写一个将资源内容从
openFile()
或可能的
openAssetFile()
管道返回的程序。显示了基本概念,尽管它使用的是
assets/
中的文件,而不是原始资源。我如何使用ContentProvider?@genialFactory:您必须编写一个将资源内容从
openFile()
或可能的
openAssetFile()
管道返回的文件。显示了基本概念,但它使用的是
assets/
中的文件,而不是原始资源。