Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

android EditTextPreference onclick

i'm making a settings activity and i want to let user picks sound notification. Im using this to do it:

EditTextPreference dataPref = (EditTextPreference) findPreference("opcion3");

        dataPref.setOnPreferenceClickListener(new OnPreferenceClickListener() {

            public boolean onPreferenceClick(Preference preference) {
                Intent intent = new Intent(RingtoneManager.ACTION_RINGTONE_PICKER);
                intent.putExtra(RingtoneManager.EXTRA_RINGTONE_TYPE, RingtoneManager.TYPE_NOTIFICATION);
                intent.putExtra(RingtoneManager.EXTRA_RINGTONE_TITLE, "Select Tone");
                intent.putExtra(RingtoneManager.EXTRA_RINGTONE_EXISTING_URI, (Uri) null);
                Ajustes.this.startActivityForResult(intent, 5);          
                return true;
            }
          });  

But when I click the EditTextPreference it shows a editbox with OK and cancel, and inmediatly it shows list of notification sounds.

How can i make it only shows the notifications sounds?

like image 215
Alexx Perez Avatar asked Jun 18 '26 19:06

Alexx Perez


1 Answers

Why do you use EditTextPreference? Use RingtonePreference or create custom Preference.

<RingtonePreference 
    android:key="notification_sound" 
    android:ringtoneType="notification" 
    android:title="Notification Sound" 
    android:defaultValue="content://settings/system/notification_sound"
    android:showDefault="true" 
    android:showSilent="true" />
like image 183
android_dev Avatar answered Jun 21 '26 08:06

android_dev



Donate For Us

If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!