2

My application worked fine when I used the original Google Music Player. It found songs and playlists, no problem. Since I started using Play Music, my application can't find any of this. Here is my code:

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

Any Idea why this happens. I just got my first complaint that someon who purchased my application could not play music.

4

1 回答 1

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);
于 2013-05-14T04:11:44.347 回答