Android ContentResolver在我的设备上找不到音乐
当我使用原始的谷歌音乐播放器时,我的应用程序运行良好。它找到了歌曲和播放列表,没有问题。因为我开始使用Play Music,所以我的应用程序找不到任何这些。这是我的密码:Android ContentResolver在我的设备上找不到音乐,android,android-contentresolver,playlists,Android,Android Contentresolver,Playlists,当我使用原始的谷歌音乐播放器时,我的应用程序运行良好。它找到了歌曲和播放列表,没有问题。因为我开始使用Play Music,所以我的应用程序找不到任何这些。这是我的密码: Cursor cursor = contentResolver.query(uri, null, MediaStore.Audio.Media.IS_MUSIC + " = 1", null, null); if (cursor == null || !cursor.moveToFirst()) {
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);