google / ringdroid

837 stars 261 forks source link

Android 10 support, it is not working on api level 29. #52

Open shubhwicked opened 5 years ago

shubhwicked commented 5 years ago

applying this projection

private static final String[] EXTERNAL_COLUMNS = new String[]{
            MediaStore.Audio.Media._ID,
            MediaStore.Audio.Media.DATA,
            MediaStore.Audio.Media.TITLE,
            MediaStore.Audio.Media.ARTIST,
            MediaStore.Audio.Media.ALBUM,
            MediaStore.Audio.Media.IS_RINGTONE,
            MediaStore.Audio.Media.IS_ALARM,
            MediaStore.Audio.Media.IS_NOTIFICATION,
            MediaStore.Audio.Media.IS_MUSIC,
            "\"" + MediaStore.Audio.Media.EXTERNAL_CONTENT_URI + "\""
    };

return Caused by: java.lang.IllegalArgumentException: Invalid column "content://media/external/audio/media". this error. Please help!

theoklink commented 5 years ago

"\"" + MediaStore.Audio.Media.EXTERNAL_CONTENT_URI + "\"" is not a column in Mediastore which is what the error states.

hungntv commented 4 years ago

@shubhwicked your code snippet is from this file https://github.com/google/ringdroid/blob/955039d67252ea7aea5a36933e8ee30110f5ec92/app/src/main/java/com/ringdroid/RingdroidSelectActivity.java#L542

Right?

shubhwicked commented 4 years ago

Yes

tuanvn2804 commented 4 years ago

Any solutions? Please post it here

umtkyck commented 4 years ago

Is there any solution?

theoklink commented 4 years ago

yes just get rid of MediaStore.Audio.Media.EXTERNAL_CONTENT_URI as this is not a column in the database. It is the uri which you would use.

    private final String track_id = MediaStore.Audio.Media._ID;
    private final String track_no = MediaStore.Audio.Media.TRACK;
    private final String track_name = MediaStore.Audio.Media.TITLE;
    private final String artist = MediaStore.Audio.Media.ARTIST;
    private final String artist_id = MediaStore.Audio.Media.ARTIST_ID;
    private final String duration = MediaStore.Audio.Media.DURATION;
    private final String album = MediaStore.Audio.Media.ALBUM;
    private final String composer = MediaStore.Audio.Media.COMPOSER;
    private final String year = MediaStore.Audio.Media.YEAR;
    private final String path = MediaStore.Audio.Media.DATA;
    private final String date_added = MediaStore.Audio.Media.DATE_ADDED;
    private final Uri uri = MediaStore.Audio.Media.EXTERNAL_CONTENT_URI;
kcochibili commented 2 years ago

like theolink suggested, remove the last item in the array to fix it; leaving you with a code like this:

private static final String[] EXTERNAL_COLUMNS = new String[]{
            MediaStore.Audio.Media._ID,
            MediaStore.Audio.Media.DATA,
            MediaStore.Audio.Media.TITLE,
            MediaStore.Audio.Media.ARTIST,
            MediaStore.Audio.Media.ALBUM,
            MediaStore.Audio.Media.IS_RINGTONE,
            MediaStore.Audio.Media.IS_ALARM,
            MediaStore.Audio.Media.IS_NOTIFICATION,
            MediaStore.Audio.Media.IS_MUSIC
    };

That is what worked for me. I am not yet sure what the consequences of removing "\"" + MediaStore.Audio.Media.EXTERNAL_CONTENT_URI + "\"" are.

theoklink commented 2 years ago

As i explained, it is the uri to access the database, not a column in a table. You have it included in your external_columns variable which is wrong, hence the error