Ringtone picker - radio button set
Asked Answered
L

2

21

I can successfully bring up a ringtone picker and get a resultant uri with the following code...

    selsound_button.setOnClickListener(new OnClickListener()
    {   
        public void onClick(View arg0)
        {
            Intent intent = new Intent(RingtoneManager.ACTION_RINGTONE_PICKER);
            intent.putExtra(RingtoneManager.EXTRA_RINGTONE_TITLE, "Select ringtone for notifications:");
            intent.putExtra(RingtoneManager.EXTRA_RINGTONE_SHOW_SILENT, false);
            intent.putExtra(RingtoneManager.EXTRA_RINGTONE_SHOW_DEFAULT, true);
            intent.putExtra(RingtoneManager.EXTRA_RINGTONE_TYPE,RingtoneManager.TYPE_ALARM);
            startActivityForResult( intent, 999);   
        }
    });

...but I have failed to work out how to do the following:

Given that I already know the current uri, I wish to tell the picker that this is currently selected so that it can have the correct radio button highlighted. At the moment none of the radiobuttons are selected at all until I press one one of them.

Lentic answered 12/9, 2012 at 16:56 Comment(0)
P
26

You need to add

   intent.putExtra(RingtoneManager.EXTRA_RINGTONE_EXISTING_URI, currenturi);

to set the radiobutton

Paulinapauline answered 18/9, 2012 at 12:25 Comment(0)
R
9

This is the Exact Code for you.

selsound_button.setOnClickListener(new OnClickListener() {

        public void onClick(View arg0) {
            final Uri currentTone= RingtoneManager.getActualDefaultRingtoneUri(YourActivity.this, RingtoneManager.TYPE_ALARM);
            Intent intent = new Intent(RingtoneManager.ACTION_RINGTONE_PICKER);
            intent.putExtra(RingtoneManager.EXTRA_RINGTONE_TYPE, RingtoneManager.TYPE_ALARM);
            intent.putExtra(RingtoneManager.EXTRA_RINGTONE_TITLE, "Select Tone");
            intent.putExtra(RingtoneManager.EXTRA_RINGTONE_EXISTING_URI, currentTone);
            intent.putExtra(RingtoneManager.EXTRA_RINGTONE_SHOW_SILENT, false);
            intent.putExtra(RingtoneManager.EXTRA_RINGTONE_SHOW_DEFAULT, true);
            startActivityForResult(intent, TONE_PICKER);
        }

    });
Richelieu answered 6/10, 2015 at 9:13 Comment(2)
This solution will add a new item "Default ringtone" and select it. but I wish it to select the exact item. If only change EXTRA_RINGTONE_SHOW_DEFAULT to false, it seems nothing will be selected.Haifa
In android 4.2.2 this shows a dialog box on screen and allow user to take required action. Can we place that dialog box on full screen at that time?Seductive

© 2022 - 2024 — McMap. All rights reserved.