Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Ringtone picker - radio button set

Tags:

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.

like image 543
Mick Avatar asked Sep 12 '12 16:09

Mick


2 Answers

You need to add

   intent.putExtra(RingtoneManager.EXTRA_RINGTONE_EXISTING_URI, currenturi); 

to set the radiobutton

like image 112
nandeesh Avatar answered Sep 29 '22 00:09

nandeesh


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);         }      }); 
like image 26
Venkatesh Selvam Avatar answered Sep 29 '22 00:09

Venkatesh Selvam