Issues setting ringtone in android 10

1k Views Asked by At

After the deprecation of getContentUriForPath() and MediaStore.MediaColumns.DATA i modified the code as below :

 private boolean SetAsRingtone(File k)
    {

        ContentValues values = new ContentValues();

        values.put(MediaStore.MediaColumns.TITLE, k.getName());
        values.put(MediaStore.MediaColumns.MIME_TYPE, "audio/mp3");
        values.put(MediaStore.Audio.Media.ARTIST, R.string.app_name);
        values.put(MediaStore.Audio.Media.IS_RINGTONE, true);
        values.put(MediaStore.Audio.Media.IS_NOTIFICATION, false);
        values.put(MediaStore.Audio.Media.IS_ALARM, false);
        values.put(MediaStore.Audio.Media.IS_MUSIC, false);

        Uri newUri=this.getContentResolver()
                .insert(MediaStore.Audio.Media.EXTERNAL_CONTENT_URI, values);

        RingtoneManager.setActualDefaultRingtoneUri(Emotes.this, RingtoneManager.TYPE_RINGTONE,
                newUri);

        return true;
    }

The problem is that the ringtone of the device does not change. I can see from the sound setting that it changed but when the phone rings the default music plays.

Any idea how i can fix this?

0

There are 0 best solutions below