我正在使用音频录制应用程序,其中将音频录制并存储在应用程序内部,并且该路径存储在SQLITE中。
我需要在whatsapp / gmail中共享该音频文件或将其保存在移动设备的内部目录中。
我尝试使用Intent共享它们,但在whatsapp中显示不受支持的格式。
我尝试了这段代码
private void Shareoption(List<RecordData> uploadlist)
{
RecordData reco2 = uploadlist.get(0);
String id3 = reco2.getId();
final RecordData recordData = DBcreatedata.getData(id3);
final File f;
locname = recordData.getRecordDataTitle();
f = new File(recordData.getRecordData());
Uri uri = Uri.parse(f.getAbsolutePath() );
Intent share = new Intent(Intent.ACTION_SEND);
share.setType("audio/*");
share.putExtra(Intent.EXTRA_STREAM, uri.toString());
startActivity(Intent.createChooser(share, "Share Sound File"));
我也对此进行了搜索,我知道在共享之前,首先必须将音频文件存储在内部目录中。所以我尝试了输入输出流方法,但是没有用。
有人可以帮助我共享此音频文件吗?
通过这种方式,我认为您的问题将得到解决
Intent sharingIntent = new Intent(Intent.ACTION_SEND);
Uri shareFileUri= Uri.parse(string);
sharingIntent.addFlags(Intent.FLAG_GRANT_READ_URI_PERMISSION);
sharingIntent.setType("*/*");
sharingIntent.putExtra(Intent.EXTRA_STREAM, shareFileUri);
sharingIntent.setFlags(Intent.FLAG_ACTIVITY_NEW_TASK);
context.startActivity(Intent.createChooser(sharingIntent, "Share Sound File"));
本文收集自互联网,转载请注明来源。
如有侵权,请联系[email protected] 删除。
我来说两句