2014-09-05 85 views
-1

此代碼在4.3和4.2中運行,但它沒有從4.4.4 Motorolla Moto G設備獲取歌曲。Android:歌曲沒有在4.4.4中顯示

這是我的代碼。

final String MEDIA_PATH = Environment.getExternalStorageDirectory() .getPath()+「/」; private ArrayList> songsList = new ArrayList>(); 公共無效BindAllSongs(){
/*
製作自定義繪製*/

String selection = MediaStore.Audio.Media.IS_MUSIC + " != 0"; 

    final String[] projection = new String[] { 
      MediaStore.Audio.Media.DISPLAY_NAME, 
      MediaStore.Audio.Media.ARTIST, 
      MediaStore.Audio.Media.DATA, 
      MediaStore.Audio.Media.DURATION}; 
      final String sortOrder = MediaStore.Audio.AudioColumns.TITLE 
        + " COLLATE LOCALIZED ASC"; 
      try { 
       // the uri of the table that we want to query 
       Uri uri = android.provider.MediaStore.Audio.Media.EXTERNAL_CONTENT_URI; 
       // query the db 

       cursor = context.getContentResolver().query(uri, 
         projection, selection, null, sortOrder); 
       if (cursor != null) { 

        cursor.moveToFirst(); 

        while (!cursor.isAfterLast()) { 

         String songTitle = cursor.getString(0); 
         String songArtist = cursor.getString(1); 
         String songData = cursor.getString(2); 
         String duration = cursor.getString(3); 
         HashMap<String, String> songMap = new HashMap<String, String>();      
         songMap.put("songTitle", songTitle); 
         songMap.put("songDuration", duration); 
         songMap.put("songAuthor", songArtist); 
         songMap.put("songPath", songData); 
         songsList.add(songMap);    
         cursor.moveToNext(); 
        } 
       } 
      } catch (Exception ex) { 
      } finally { 
       if(cursor == null) 
       { 
        AlertDialog("No Song Found from your Device"); 
       } 
       else if (cursor !=null) 
       { 
        AlertDialog(String.valueOf(cursor.getCount()) + " Song Found"); 
       } 

       if (cursor != null) { 
        cursor.close(); 
       } 
      }* 

這個代碼是沒有得到摩托羅拉摹4.4.4.How任何一首歌曲可以解決這個問題?

回答

0

我已經通過在其中添加查詢來解決此問題,而不是比較擴展名。