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?
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" />
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With