我正在尝试从第3个应用程序到我的Android应用程序共享音频(.mp3) . 当我收到音频并获得意图信息(Uri soundUri =(Uri)intent.getParcelableExtra(Intent.EXTRA_STREAM))时,Uri有错误的数据 . 路径正确但文件名已用数字重命名(例如5348)且没有扩展名,真实文件名为AUDIO-6151616.mp3
所以,完整路径是/storage/emulated/0/Download/AUDIO-6151616.mp3但是我的Intent Uri是/ storage / emulated / 0 / Download / 5348
如果我从另一个第三方应用程序(我正在使用文件浏览器应用程序)共享此音频,它似乎工作正常,但如果我使用其他应用程序甚至“本机”下载应用程序(在Moto G上)它没有 .
我错过了什么?
提前致谢
1 回答
你应该看看official training docs for sharing . 你应该总是期待
content://
uri就像content://Download/5348
. 因为你想调用getContentResolver().openInputStream(uri)
. 所以你最终可以使用ShareCompat.IntentReader .其他值得关注的推荐研究是:
Sharing Content (Android Development Patterns S2 Ep 6)
Forget the Storage Permission: Alternatives for sharing and collaborating (Big Android BBQ 2015)