android - 如何在 android 中将特定的 SQLITE 音频文件共享到 Gmail?
问题描述
我正在使用录音应用程序,其中音频被记录并存储在应用程序中,并且该路径存储在 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"));
推荐阅读
- embedded - UDR 寄存器始终读取 0xFF
- android - 仅在 Ionic-Android 应用程序启动时触发功能
- c# - LINQ 用于获取每个不同名称的 5 条最新记录
- reactjs - 依赖于多个先前 refetchInterval 查询的串行查询
- python - 在 Python 中检测颜色的最简单方法是什么?
- python - Python 3.8.0 总是从同一目录中的导入中获得 linting 警告或 ModuleNotFoundError
- angular - 从返回的 URL 中获取参数
- sprite-kit - 如何在 SpriteKit 中实现对齐中心?
- javascript - 更新 API 时更新 HTML 表
- c# - 保护 RabbitMQ 消息