Android ContentResolver在我的设备上找不到音乐



我的应用程序工作良好,当我使用原来的谷歌音乐播放器。它能找到歌曲和播放列表,没问题。自从我开始使用Play Music,我的应用程序就找不到这些了。下面是我的代码:

    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();

知道为什么会这样吗?我刚收到我的第一个投诉,有人购买了我的应用程序不能播放音乐。

可能是晚了,但我做了这样的事情:

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);

最新更新