RingtonePreference
open classRingtonePreference: Preference, PreferenceManager.OnActivityResultListener
| kotlin.Any | ||
| ↳ | android.preference.Preference | |
| ↳ | android.preference.RingtonePreference | |
A Preference that allows the user to choose a ringtone from those on the device. The chosen ringtone's URI will be persisted as a string.
If the user chooses the "Default" item, the saved string will be one of System.DEFAULT_RINGTONE_URI, System.DEFAULT_NOTIFICATION_URI, or System.DEFAULT_ALARM_ALERT_URI. If the user chooses the "Silent" item, the saved string will be an empty string.
Summary
| XML attributes | |
|---|---|
android:ringtoneType |
Which ringtone type(s) to show in the picker. |
android:showDefault |
Whether to show an item for a default sound. |
android:showSilent |
Whether to show an item for 'Silent'. |
| Inherited XML attributes | |
|---|---|
| Inherited constants | |
|---|---|
| Public constructors | |
|---|---|
RingtonePreference(context: Context!) |
|
RingtonePreference(context: Context!, attrs: AttributeSet!) |
|
RingtonePreference(context: Context!, attrs: AttributeSet!, defStyleAttr: Int) |
|
RingtonePreference(context: Context!, attrs: AttributeSet!, defStyleAttr: Int, defStyleRes: Int) |
|
| Public methods | |
|---|---|
| open Int |
Returns the sound type(s) that are shown in the picker. |
| open Boolean |
Returns whether to a show an item for the default sound/ringtone. |
| open Boolean |
Returns whether to a show an item for 'Silent'. |
| open Boolean |
onActivityResult(requestCode: Int, resultCode: Int, data: Intent!)See Activity's onActivityResult. |
| open Unit |
setRingtoneType(type: Int)Sets the sound type(s) that are shown in the picker. |
| open Unit |
setShowDefault(showDefault: Boolean)Sets whether to show an item for the default sound/ringtone. |
| open Unit |
setShowSilent(showSilent: Boolean)Sets whether to show an item for 'Silent'. |
| Protected methods | |
|---|---|
| open Unit |
onAttachedToHierarchy(preferenceManager: PreferenceManager!)Called when this Preference has been attached to a Preference hierarchy. |
| open Unit |
onClick()Processes a click on the preference. |
| open Any! |
onGetDefaultValue(a: TypedArray!, index: Int)Called when a Preference is being inflated and the default value attribute needs to be read. |
| open Unit |
onPrepareRingtonePickerIntent(ringtonePickerIntent: Intent!)Prepares the intent to launch the ringtone picker. |
| open Uri! |
Called when the chooser is about to be shown and the current ringtone should be marked. |
| open Unit |
onSaveRingtone(ringtoneUri: Uri!)Called when a ringtone is chosen. |
| open Unit |
onSetInitialValue(restorePersistedValue: Boolean, defaultValueObj: Any!)Implement this to set the initial value of the Preference. |
| Inherited functions | |
|---|---|
XML attributes
android:ringtoneType
android:ringtoneTypeMust be one or more (separated by '|') of the following constant values.
| Constant | Value | Description |
|---|---|---|
| alarm | 4 | Alarm sounds. |
| all | 7 | All available ringtone sounds. |
| notification | 2 | Notification sounds. |
| ringtone | 1 | Ringtones. |
android:showDefault
android:showDefaultMay be a boolean value, such as "true" or "false".
android:showSilent
android:showSilentMay be a boolean value, such as "true" or "false".
Public constructors
RingtonePreference
RingtonePreference(
context: Context!,
attrs: AttributeSet!)
RingtonePreference
RingtonePreference(
context: Context!,
attrs: AttributeSet!,
defStyleAttr: Int)
RingtonePreference
RingtonePreference(
context: Context!,
attrs: AttributeSet!,
defStyleAttr: Int,
defStyleRes: Int)
Public methods
getRingtoneType
open fungetRingtoneType(): Int
Deprecated: Deprecated in Java.
Returns the sound type(s) that are shown in the picker.
| Return | |
|---|---|
Int |
The sound type(s) that are shown in the picker. |
See Also
getShowDefault
open fungetShowDefault(): Boolean
Deprecated: Deprecated in Java.
Returns whether to a show an item for the default sound/ringtone.
| Return | |
|---|---|
Boolean |
Whether to show an item for the default sound/ringtone. |
getShowSilent
open fungetShowSilent(): Boolean
Deprecated: Deprecated in Java.
Returns whether to a show an item for 'Silent'.
| Return | |
|---|---|
Boolean |
Whether to show an item for 'Silent'. |
onActivityResult
open funonActivityResult(
requestCode: Int,
resultCode: Int,
data: Intent!
): Boolean
Deprecated: Deprecated in Java.
See Activity's onActivityResult.
| Return | |
|---|---|
Boolean |
Whether the request code was handled (in which case subsequent listeners will not be called. |
setRingtoneType
open funsetRingtoneType(type: Int): Unit
Deprecated: Deprecated in Java.
Sets the sound type(s) that are shown in the picker.
| Parameters | |
|---|---|
type |
Int: The sound type(s) that are shown in the picker. |
setShowDefault
open funsetShowDefault(showDefault: Boolean): Unit
Deprecated: Deprecated in Java.
Sets whether to show an item for the default sound/ringtone. The default to use will be deduced from the sound type(s) being shown.
| Parameters | |
|---|---|
showDefault |
Boolean: Whether to show the default or not. |
setShowSilent
open funsetShowSilent(showSilent: Boolean): Unit
Deprecated: Deprecated in Java.
Sets whether to show an item for 'Silent'.
| Parameters | |
|---|---|
showSilent |
Boolean: Whether to show 'Silent'. |
Protected methods
onAttachedToHierarchy
protected open funonAttachedToHierarchy(preferenceManager: PreferenceManager!): Unit
Deprecated: Deprecated in Java.
Called when this Preference has been attached to a Preference hierarchy. Make sure to call the super implementation.
| Parameters | |
|---|---|
preferenceManager |
PreferenceManager!: The PreferenceManager of the hierarchy. |
onClick
protected open funonClick(): Unit
Deprecated: Deprecated in Java.
Processes a click on the preference. This includes saving the value to the SharedPreferences. However, the overridden method should call callChangeListener(java.lang.Object) to make sure the client wants to update the preference's state with the new value.
onGetDefaultValue
protected open funonGetDefaultValue(
a: TypedArray!,
index: Int
): Any!
Deprecated: Deprecated in Java.
Called when a Preference is being inflated and the default value attribute needs to be read. Since different Preference types have different value types, the subclass should get and return the default value which will be its value type.
For example, if the value type is String, the body of the method would proxy to TypedArray.getString(int).
| Parameters | |
|---|---|
a |
TypedArray!: The set of attributes. |
index |
Int: The index of the default value attribute. |
| Return | |
|---|---|
Any! |
The default value of this preference type. |
onPrepareRingtonePickerIntent
protected open funonPrepareRingtonePickerIntent(ringtonePickerIntent: Intent!): Unit
Deprecated: Deprecated in Java.
Prepares the intent to launch the ringtone picker. This can be modified to adjust the parameters of the ringtone picker.
| Parameters | |
|---|---|
ringtonePickerIntent |
Intent!: The ringtone picker intent that can be modified by putting extras. |
onRestoreRingtone
protected open funonRestoreRingtone(): Uri!
Deprecated: Deprecated in Java.
Called when the chooser is about to be shown and the current ringtone should be marked. Can return null to not mark any ringtone.
By default, this restores the previous ringtone URI from the persistent storage.
| Return | |
|---|---|
Uri! |
The ringtone to be marked as the current ringtone. |
onSaveRingtone
protected open funonSaveRingtone(ringtoneUri: Uri!): Unit
Deprecated: Deprecated in Java.
Called when a ringtone is chosen.
By default, this saves the ringtone URI to the persistent storage as a string.
| Parameters | |
|---|---|
ringtoneUri |
Uri!: The chosen ringtone's Uri. Can be null. |
onSetInitialValue
protected open funonSetInitialValue(
restorePersistedValue: Boolean,
defaultValueObj: Any!
): Unit
Deprecated: Deprecated in Java.
Implement this to set the initial value of the Preference.
If restorePersistedValue is true, you should restore the Preference value from the android.content.SharedPreferences. If restorePersistedValue is false, you should set the Preference value to defaultValue that is given (and possibly store to SharedPreferences if shouldPersist() is true).
In case of using PreferenceDataStore, the restorePersistedValue is always true. But the default value (if provided) is set.
This may not always be called. One example is if it should not persist but there is no default value given.
| Parameters | |
|---|---|
restorePersistedValue |
Boolean: True to restore the persisted value; false to use the given defaultValue. |
defaultValue |
The default value for this Preference. Only use this if restorePersistedValue is false. |