2013-04-03 52 views
1

當我使用原始的Google音樂播放器時,我的應用程序正常工作。它找到了歌曲和播放列表,沒問題。自從我開始使用Play音樂以來,我的應用程序找不到任何這樣的內容。這裏是我的代碼:Android ContentResolver在我的設備上找不到音樂

Cursor cursor = contentResolver.query(uri, null, MediaStore.Audio.Media.IS_MUSIC + " = 1", null, null); 

    if (cursor == null || !cursor.moveToFirst()) { 
     Log.e(TAG, "Could not locate any music on device."); 
     return; 
    } 

    cursor.close(); 

任何想法爲什麼發生這種情況。我剛剛收到我的第一個投訴,說有人購買我的應用程序無法播放音樂。

回答

3

也許它晚,但我做這樣的事情:

String[] projection = { 
      MediaStore.Audio.Media._ID, 
      MediaStore.Audio.Media.ARTIST, 
      MediaStore.Audio.Media.TITLE, 
      MediaStore.Audio.Media.DATA, 
      MediaStore.Audio.Media.DISPLAY_NAME, 
      MediaStore.Audio.Media.ALBUM_ID, 
      MediaStore.Audio.Media.DURATION 
    }; 
    String selection = MediaStore.Audio.Media.IS_MUSIC + " != 0"; 
    Cursor cursor = context.getContentResolver().query(
      MediaStore.Audio.Media.EXTERNAL_CONTENT_URI, 
      projection, 
      selection, 
      null, 
      null); 
相關問題