How to get current ringtone in Android?

后端 未结 6 1316
情书的邮戳
情书的邮戳 2020-12-10 04:50

I have found lots of examples how to get default ringtone. Something like that:

Uri alert = RingtoneManager.getDefaultUri(RingtoneManager.TYPE_RINGTONE);
            


        
6条回答
  •  遥遥无期
    2020-12-10 05:09

    I've also searched a lot for your problem which I also had. At last got solution from this itself.

    Use below code in the button for ringtone intent.

    public void pickRingtone(View view) {
            // TODO Auto-generated method.stub
    
            Intent intent = new Intent(RingtoneManager.ACTION_RINGTONE_PICKER);
            intent.putExtra(RingtoneManager.EXTRA_RINGTONE_TYPE, RingtoneManager.TYPE_RINGTONE);
            intent.putExtra(RingtoneManager.EXTRA_RINGTONE_TITLE, "Select Ringtone");
    
        // for existing ringtone
            Uri urie = RingtoneManager.getActualDefaultRingtoneUri(
                    getApplicationContext(), RingtoneManager.TYPE_RINGTONE);
            intent.putExtra(RingtoneManager.EXTRA_RINGTONE_EXISTING_URI, urie);
    
        startActivityForResult(intent, 5);
    }
    

提交回复
热议问题