How to get the mp3 file of default / current ringtone in android

588 views Asked by At

I am developing a fake call application, I wanted to get the mp3 file of the current ringtone so that I can use it in another application for creating the fake call with the same ringtone file. I have searched a lot but cannot find the right solution. Still, I am using this code to play the current ringtone. Is there any way to get the mp3 file of this ringtone.

public void onClick(View view) {
    Uri defaultRintoneUri = RingtoneManager.getActualDefaultRingtoneUri(getApplicationContext(), RingtoneManager.TYPE_RINGTONE);
    Ringtone defaultRingtone = RingtoneManager.getRingtone(getApplicationContext(), defaultRintoneUri);
    defaultRingtone.play();
}
1

There are 1 answers

0
AudioBubble On
private Uri getCurrentSound(){

    Uri ringtone_uri  = RingtoneManager.getActualDefaultRingtoneUri(MainActivity.this, RingtoneManager.TYPE_RINGTONE);

    if(ringtone_uri == null){
        // if ringtone_uri is null get Default Ringtone
        ringtone_uri = RingtoneManager.getDefaultUri(RingtoneManager.TYPE_RINGTONE);
    }

    return  ringtone_uri;
}