简体   繁体   English

如果Uri指向使用FileExplorer重命名的文件,则MediaPlayer.create(Context,Uri)返回null

[英]MediaPlayer.create(Context, Uri) returns null, if Uri points to a file which has been renamed using FileExplorer

MediaPlayer.create(Context, Uri) returns null. MediaPlayer.create(Context, Uri)返回null。 I change the path of some file using FileExplorer app and then Uri points to that file. 我使用FileExplorer应用程序更改某个文件的路径,然后Uri指向该文件。 Uri is absolutely correct. Uri是完全正确的。 But, I'm getting null instead of MediaPlayer object from this method. 但是,我从这个方法得到null而不是MediaPlayer对象。 Any help? 有帮助吗?

I faced this problem in the past.After renaming that file, just check, whether that file can be opened from outside of your app. 我在过去遇到过这个问题。重命名该文件后,只需检查该文件是否可以从您的应用程序外部打开。

I'm sure, that file cannot be opened. 我敢肯定,该文件无法打开。

So, just place a null check and show a Toast to the user. 因此,只需放置一个空检查并向用户显示Toast。

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM