java.lang.Object | |
↳ | android.media.RingtoneManager |
RingtoneManager provides access to ringtones, notification, and other types
of sounds. It manages querying the different media providers and combines the
results into a single cursor. It also provides a Ringtone
for each
ringtone. We generically call these sounds ringtones, however the
TYPE_RINGTONE
refers to the type of sounds that are suitable for the
phone ringer.
To show a ringtone picker to the user, use the
ACTION_RINGTONE_PICKER
intent to launch the picker as a subactivity.
Constants | |||||||||||
---|---|---|---|---|---|---|---|---|---|---|---|
String | ACTION_RINGTONE_PICKER | Activity Action: Shows a ringtone picker. | |||||||||
String | EXTRA_RINGTONE_DEFAULT_URI | Given to the ringtone picker as a Uri . |
|||||||||
String | EXTRA_RINGTONE_EXISTING_URI | Given to the ringtone picker as a Uri . |
|||||||||
String | EXTRA_RINGTONE_INCLUDE_DRM | This constant was deprecated in API level 19. DRM ringtones are no longer supported | |||||||||
String | EXTRA_RINGTONE_PICKED_URI | Returned from the ringtone picker as a Uri . |
|||||||||
String | EXTRA_RINGTONE_SHOW_DEFAULT | Given to the ringtone picker as a boolean. | |||||||||
String | EXTRA_RINGTONE_SHOW_SILENT | Given to the ringtone picker as a boolean. | |||||||||
String | EXTRA_RINGTONE_TITLE | Given to the ringtone picker as a CharSequence . |
|||||||||
String | EXTRA_RINGTONE_TYPE | Given to the ringtone picker as an int. | |||||||||
int | ID_COLUMN_INDEX | The column index (in the cursor returned by getCursor() for the
row ID. |
|||||||||
int | TITLE_COLUMN_INDEX | The column index (in the cursor returned by getCursor() for the
title. |
|||||||||
int | TYPE_ALARM | Type that refers to sounds that are used for the alarm. | |||||||||
int | TYPE_ALL | All types of sounds. | |||||||||
int | TYPE_NOTIFICATION | Type that refers to sounds that are used for notifications. | |||||||||
int | TYPE_RINGTONE | Type that refers to sounds that are used for the phone ringer. | |||||||||
int | URI_COLUMN_INDEX | The column index (in the cursor returned by getCursor() for the
media provider's URI. |
Public Constructors | |||||||||||
---|---|---|---|---|---|---|---|---|---|---|---|
Constructs a RingtoneManager.
| |||||||||||
Constructs a RingtoneManager.
|
Public Methods | |||||||||||
---|---|---|---|---|---|---|---|---|---|---|---|
Gets the current default sound's
Uri . | |||||||||||
Returns a
Cursor of all the ringtones available. | |||||||||||
Returns the type of a default
Uri . | |||||||||||
Returns the
Uri for the default ringtone of a particular type. | |||||||||||
This method was deprecated
in API level 19.
DRM ringtones are no longer supported
| |||||||||||
Returns a
Ringtone for a given sound URI. | |||||||||||
Gets the position of a
Uri within this RingtoneManager . | |||||||||||
Returns a valid ringtone URI.
| |||||||||||
Infers the playback stream type based on what type of ringtones this
manager is returning.
| |||||||||||
Returns whether the given
Uri is one of the default ringtones. | |||||||||||
Sets the
Uri of the default sound for a given sound type. | |||||||||||
This method was deprecated
in API level 19.
DRM ringtones are no longer supported
| |||||||||||
Sets which type(s) of ringtones will be listed by this.
| |||||||||||
Stops playing the last
Ringtone retrieved from this. |
[Expand]
Inherited Methods | |||||||||||
---|---|---|---|---|---|---|---|---|---|---|---|
From class
java.lang.Object
|
Activity Action: Shows a ringtone picker.
Input: EXTRA_RINGTONE_EXISTING_URI
,
EXTRA_RINGTONE_SHOW_DEFAULT
,
EXTRA_RINGTONE_SHOW_SILENT
, EXTRA_RINGTONE_TYPE
,
EXTRA_RINGTONE_DEFAULT_URI
, EXTRA_RINGTONE_TITLE
,
Output: EXTRA_RINGTONE_PICKED_URI
.
Given to the ringtone picker as a Uri
. The Uri
of the
ringtone to play when the user attempts to preview the "Default"
ringtone. This can be one of DEFAULT_RINGTONE_URI
,
DEFAULT_NOTIFICATION_URI
, or
DEFAULT_ALARM_ALERT_URI
to have the "Default" point to
the current sound for the given default sound type. If you are showing a
ringtone picker for some other type of sound, you are free to provide any
Uri
here.
Given to the ringtone picker as a Uri
. The Uri
of the
current ringtone, which will be used to show a checkmark next to the item
for this Uri
. If showing an item for "Default" (@see
EXTRA_RINGTONE_SHOW_DEFAULT
), this can also be one of
DEFAULT_RINGTONE_URI
,
DEFAULT_NOTIFICATION_URI
, or
DEFAULT_ALARM_ALERT_URI
to have the "Default" item
checked.
This constant was deprecated
in API level 19.
DRM ringtones are no longer supported
Given to the ringtone picker as a boolean. Whether to include DRM ringtones.
Returned from the ringtone picker as a Uri
.
It will be one of:
Uri
that equals DEFAULT_RINGTONE_URI
,
DEFAULT_NOTIFICATION_URI
, or
DEFAULT_ALARM_ALERT_URI
if the default was chosen,
Given to the ringtone picker as a boolean. Whether to show an item for "Default".
Given to the ringtone picker as a boolean. Whether to show an item for
"Silent". If the "Silent" item is picked,
EXTRA_RINGTONE_PICKED_URI
will be null.
Given to the ringtone picker as a CharSequence
. The title to
show for the ringtone picker. This has a default value that is suitable
in most cases.
Given to the ringtone picker as an int. Specifies which ringtone type(s) should be
shown in the picker. One or more of TYPE_RINGTONE
,
TYPE_NOTIFICATION
, TYPE_ALARM
, or TYPE_ALL
(bitwise-ored together).
The column index (in the cursor returned by getCursor()
for the
row ID.
The column index (in the cursor returned by getCursor()
for the
title.
Type that refers to sounds that are used for the alarm.
All types of sounds.
Type that refers to sounds that are used for notifications.
Type that refers to sounds that are used for the phone ringer.
The column index (in the cursor returned by getCursor()
for the
media provider's URI.
Constructs a RingtoneManager. This constructor is recommended as its constructed instance manages cursor(s).
activity | The activity used to get a managed cursor. |
---|
Constructs a RingtoneManager. The instance constructed by this constructor will not manage the cursor(s), so the client should handle this itself.
context | The context to used to get a cursor. |
---|
Gets the current default sound's Uri
. This will give the actual
sound Uri
, instead of using this, most clients can use
DEFAULT_RINGTONE_URI
.
context | A context used for querying. |
---|---|
type | The type whose default sound should be returned. One of
TYPE_RINGTONE , TYPE_NOTIFICATION , or
TYPE_ALARM . |
Uri
pointing to the default sound for the sound type.Returns a Cursor
of all the ringtones available. The returned
cursor will be the same cursor returned each time this method is called,
so do not close()
the cursor. The cursor can be
deactivate()
safely.
If RingtoneManager(Activity)
was not used, the
caller should manage the returned cursor through its activity's life
cycle to prevent leaking the cursor.
Cursor
of all the ringtones available.Returns the type of a default Uri
.
defaultRingtoneUri | The default Uri . For example,
DEFAULT_RINGTONE_URI ,
DEFAULT_NOTIFICATION_URI , or
DEFAULT_ALARM_ALERT_URI . |
---|
Returns the Uri
for the default ringtone of a particular type.
Rather than returning the actual ringtone's sound Uri
, this will
return the symbolic Uri
which will resolved to the actual sound
when played.
type | The ringtone type whose default should be returned. |
---|
Uri
of the default ringtone for the given type.
This method was deprecated
in API level 19.
DRM ringtones are no longer supported
Returns whether DRM ringtones will be included.
Returns a Ringtone
for a given sound URI.
If the given URI cannot be opened for any reason, this method will attempt to fallback on another sound. If it cannot find any, it will return null.
context | A context used to query. |
---|---|
ringtoneUri | The Uri of a sound or ringtone. |
Ringtone
for the given URI, or null.
Gets the position of a Uri
within this RingtoneManager
.
ringtoneUri | The Uri to retreive the position of. |
---|
Uri
, or -1 if it cannot be found.
Returns a valid ringtone URI. No guarantees on which it returns. If it cannot find one, returns null.
context | The context to use for querying. |
---|
Infers the playback stream type based on what type of ringtones this manager is returning.
Sets the Uri
of the default sound for a given sound type.
context | A context used for querying. |
---|---|
type | The type whose default sound should be set. One of
TYPE_RINGTONE , TYPE_NOTIFICATION , or
TYPE_ALARM . |
ringtoneUri | A Uri pointing to the default sound to set. |
This method was deprecated
in API level 19.
DRM ringtones are no longer supported
Sets whether to include DRM ringtones.
includeDrm | Whether to include DRM ringtones. Obsolete - no longer has any effect |
---|
Sets which type(s) of ringtones will be listed by this.
type | The type(s), one or more of TYPE_RINGTONE ,
TYPE_NOTIFICATION , TYPE_ALARM ,
TYPE_ALL . |
---|
Stops playing the last Ringtone
retrieved from this.