java - 从 url 共享音频文件
问题描述
我想从一个 url 共享一个音频文件(url 是 audio.getUrl())我试图先下载文件然后共享它但是当我在我的智能手机中尝试时它关闭了应用程序。你能告诉我任何其他方法吗?请帮忙。
DownloadManager downloadManager = (DownloadManager) v.getContext().getSystemService(Context.DOWNLOAD_SERVICE);
Uri uri = Uri.parse(audio.getUrl());
DownloadManager.Request request = new DownloadManager.Request(uri);
request.setAllowedNetworkTypes(
DownloadManager.Request.NETWORK_WIFI
| DownloadManager.Request.NETWORK_MOBILE)
.setDestinationInExternalPublicDir("/sdcard/download/", "audio.mp3");
downloadManager.enqueue(request);
Intent compartirAudio = new Intent(android.content.Intent.ACTION_SEND);
compartirAudio.setType("audio/*");
compartirAudio.putExtra(Intent.EXTRA_STREAM,Uri.parse("/sdcard/download/audio.mp3"));
v.getContext().startActivity(Intent.createChooser(compartirAudio, "Share"));
解决方案
推荐阅读
- c - 为什么我不能在 C 中使用连续实现将元素插入到列表中?
- javascript - 未定义的方法 `comment_url' 用于#
- c# - 从 2.2 迁移到 3.1 后 EF Core 出现问题
- vba - 向地址条目添加/删除地址条目
- web-scraping - 从下拉列表中选择元素并等待页面呈现内容的完美 Lua_Script
- hyperledger-fabric - Hyperledger Caliper 事务生命周期错误:peer 2 提出的响应错误未知:访问被拒绝通道 [] creator org
- python - 如何计算 LightGBM 分类器中的叶值?
- git - 通过 https 部署时的 git 推送错误消息
- c# - 在具有许多客户端的服务器中使用一个端口与多个端口?
- java - 异步 JAX-RS 实现中的 NullPointerException