Warning: file_get_contents(/data/phpspider/zhask/data//catemap/3/android/223.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
Android setDataSource失败0x8000000_Android - Fatal编程技术网

Android setDataSource失败0x8000000

Android setDataSource失败0x8000000,android,Android,使用MediaMetadataRetriever检索mp3文件的艺术家和标题时,我收到一个错误(setDataSource失败0x8000000),但我无法理解原因。在我的模拟器上运行时,它工作得很好,但在我的三星S4上运行时崩溃。我知道目录是正确的(/storage/extSdCard/Music/),因为我可以毫无问题地加载文件名。有人能解释一下为什么这不起作用吗 if (songs.size() != 0){ for (int x = 0; x &l

使用MediaMetadataRetriever检索mp3文件的艺术家和标题时,我收到一个错误(setDataSource失败0x8000000),但我无法理解原因。在我的模拟器上运行时,它工作得很好,但在我的三星S4上运行时崩溃。我知道目录是正确的(/storage/extSdCard/Music/),因为我可以毫无问题地加载文件名。有人能解释一下为什么这不起作用吗

        if (songs.size() != 0){
            for (int x = 0; x < songs.size(); x++){
                MediaMetadataRetriever mmr = new MediaMetadataRetriever();
                mmr.setDataSource(SD_PATH + songs.get(x));

                String tagTitle =
                     mmr.extractMetadata(MediaMetadataRetriever.METADATA_KEY_TITLE);
                String tagArtist =
                     mmr.extractMetadata(MediaMetadataRetriever.METADATA_KEY_ARTIST);


                taggedSongs.add(tagArtist + " - " + tagTitle);
            }

            ArrayAdapter<String> songList = new ArrayAdapter<String>(this,R.layout.song_item,taggedSongs);

在我的例子中,问题是因为我忘记设置互联网权限,而我的应用程序需要访问互联网。新手错误。

将setDataSource()方法放入try-catch块解决了该问题

  try {
            metaRetriver.setDataSource(AudioPath);
           //
        } catch (Exception e) {
            //
        }

抱歉,我刚刚编辑了我的文章,将其包括在内。您是否设置了
写入外部存储
-权限?问题已解决,这是由没有任何标记的文件引起的。我还不能回答我自己的问题,因为我没有足够的代表,所以我将稍后更新。它是由没有任何标记的文件引起的。嘿,你现在能回答你的问题吗?
  try {
            metaRetriver.setDataSource(AudioPath);
           //
        } catch (Exception e) {
            //
        }