Warning: file_get_contents(/data/phpspider/zhask/data//catemap/3/android/178.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
Android(Java)中的无效令牌为\u音乐错误_Android_Android Sqlite_Android Contentresolver_Android 11 - Fatal编程技术网

Android(Java)中的无效令牌为\u音乐错误

Android(Java)中的无效令牌为\u音乐错误,android,android-sqlite,android-contentresolver,android-11,Android,Android Sqlite,Android Contentresolver,Android 11,我有一个音乐应用程序。现在,我想把我的音乐应用升级到Android 11。我正在使用“游标”搜索音乐文件。但是,我得到了一个错误。我搜索了错误消息并执行了此解决方案,但任何解决方案都无法解决我的问题。我将分享代码片段并发布详细信息。有人能帮我解决这个问题吗 代码片段 错误细节 我在这方面遇到了一个错误musicCursor=application.getContentResolver().query(MediaStore.Files.getContentUri(“外部”),null,bundle

我有一个音乐应用程序。现在,我想把我的音乐应用升级到Android 11。我正在使用“游标”搜索音乐文件。但是,我得到了一个错误。我搜索了错误消息并执行了此解决方案,但任何解决方案都无法解决我的问题。我将分享代码片段并发布详细信息。有人能帮我解决这个问题吗

代码片段

错误细节

我在这方面遇到了一个错误musicCursor=application.getContentResolver().query(MediaStore.Files.getContentUri(“外部”),null,bundle,null)

谢谢

ContentResolver musicResolver = application.getContentResolver();
String SONG_WHERE_CLAUSE;
Cursor musicCursor;

if (android.os.Build.VERSION.SDK_INT >= android.os.Build.VERSION_CODES.R) {
    String[] selectionArgs;
    if (scanAll) {
        SONG_WHERE_CLAUSE = "duration > ?";
        selectionArgs = new String[1];
        selectionArgs[0] = "5000";
    } else {
        SONG_WHERE_CLAUSE = MediaStore.Audio.AudioColumns.DURATION + " > ? AND " + MediaStore.Audio.AudioColumns.IS_MUSIC + " = ?";
        selectionArgs = new String[2];
        selectionArgs[0] = "3000";
        selectionArgs[1] = "1";
    }
    Bundle bundle = new Bundle();
    bundle.putInt(ContentResolver.QUERY_ARG_LIMIT, 50);
    bundle.putInt(ContentResolver.QUERY_ARG_SORT_DIRECTION, ContentResolver.QUERY_SORT_DIRECTION_DESCENDING);
    bundle.putString(ContentResolver.QUERY_ARG_SORT_COLUMNS, MediaStore.MediaColumns.DATE_ADDED);
    bundle.putString(ContentResolver.QUERY_ARG_SQL_SELECTION, SONG_WHERE_CLAUSE);
    bundle.putStringArray(ContentResolver.QUERY_ARG_SQL_SELECTION_ARGS, selectionArgs);
    musicCursor = application.getContentResolver().query(MediaStore.Files.getContentUri("external"), null, bundle, null);
} else {
    SONG_WHERE_CLAUSE = "duration > 3000 AND " + MediaStore.Audio.Media.IS_MUSIC + " = 1";
    if (scanAll)
        SONG_WHERE_CLAUSE = "duration > 5000";
    musicCursor = musicResolver.query(musicUri, null, SONG_WHERE_CLAUSE, null, MEDIA_SORT);
}
 java.lang.IllegalArgumentException: Invalid token is_music
    at android.database.DatabaseUtils.readExceptionFromParcel(DatabaseUtils.java:172)
    at android.database.DatabaseUtils.readExceptionFromParcel(DatabaseUtils.java:142)
    at android.content.ContentProviderProxy.query(ContentProviderNative.java:472)
    at android.content.ContentResolver.query(ContentResolver.java:1183)