【问题标题】:Android ContentResolver does not find music on my deviceAndroid ContentResolver 在我的设备上找不到音乐
【发布时间】:2013-04-03 04:05:36
【问题描述】:

当我使用原始的 Google 音乐播放器时,我的应用程序运行良好。它找到歌曲和播放列表,没问题。自从我开始使用 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();

知道为什么会发生这种情况。我刚收到我的第一个投诉,即购买我的应用程序的人无法播放音乐。

【问题讨论】:

    标签: android android-contentresolver playlists


    【解决方案1】:

    也许已经晚了,但我会这样做:

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

    【讨论】:

      猜你喜欢
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 2012-05-04
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      相关资源
      最近更新 更多