|
Build 1.0_r1(from source) | |||||||||
| PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||||
| SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD | |||||||||
java.lang.Objectandroid.media.RingtoneManager
public class 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.
Ringtone| Field Summary | |
|---|---|
static String |
ACTION_RINGTONE_PICKER
Activity Action: Shows a ringtone picker. |
static String |
EXTRA_RINGTONE_DEFAULT_URI
Given to the ringtone picker as a Uri. |
static String |
EXTRA_RINGTONE_EXISTING_URI
Given to the ringtone picker as a Uri. |
static String |
EXTRA_RINGTONE_INCLUDE_DRM
Given to the ringtone picker as a boolean. |
static String |
EXTRA_RINGTONE_PICKED_URI
Returned from the ringtone picker as a Uri. |
static String |
EXTRA_RINGTONE_SHOW_DEFAULT
Given to the ringtone picker as a boolean. |
static String |
EXTRA_RINGTONE_SHOW_SILENT
Given to the ringtone picker as a boolean. |
static String |
EXTRA_RINGTONE_TITLE
Given to the ringtone picker as a CharSequence. |
static String |
EXTRA_RINGTONE_TYPE
Given to the ringtone picker as an int. |
static int |
ID_COLUMN_INDEX
The column index (in the cursor returned by getCursor() for the
row ID. |
static int |
TITLE_COLUMN_INDEX
The column index (in the cursor returned by getCursor() for the
title. |
static int |
TYPE_ALARM
Type that refers to sounds that are used for the alarm. |
static int |
TYPE_ALL
All types of sounds. |
static int |
TYPE_NOTIFICATION
Type that refers to sounds that are used for notifications. |
static int |
TYPE_RINGTONE
Type that refers to sounds that are used for the phone ringer. |
static int |
URI_COLUMN_INDEX
The column index (in the cursor returned by getCursor() for the
media provider's URI. |
| Constructor Summary | |
|---|---|
RingtoneManager(Activity activity)
Constructs a RingtoneManager. |
|
RingtoneManager(Context context)
Constructs a RingtoneManager. |
|
| Method Summary | |
|---|---|
static Uri |
getActualDefaultRingtoneUri(Context context,
int type)
Gets the current default sound's Uri. |
Cursor |
getCursor()
Returns a Cursor of all the ringtones available. |
static int |
getDefaultType(Uri defaultRingtoneUri)
Returns the type of a default Uri. |
static Uri |
getDefaultUri(int type)
Returns the Uri for the default ringtone of a particular type. |
boolean |
getIncludeDrm()
Returns whether DRM ringtones will be included. |
static Ringtone |
getRingtone(Context context,
Uri ringtoneUri)
Returns a Ringtone for a given sound URI. |
Ringtone |
getRingtone(int position)
Gets a Ringtone for the ringtone at the given position in the
Cursor. |
int |
getRingtonePosition(Uri ringtoneUri)
Gets the position of a Uri within this RingtoneManager. |
Uri |
getRingtoneUri(int position)
Gets a Uri for the ringtone at the given position in the Cursor. |
boolean |
getStopPreviousRingtone()
|
static Uri |
getValidRingtoneUri(Context context)
Returns a valid ringtone URI. |
static boolean |
isDefault(Uri ringtoneUri)
Returns whether the given Uri is one of the default ringtones. |
static void |
setActualDefaultRingtoneUri(Context context,
int type,
Uri ringtoneUri)
Sets the Uri of the default sound for a given sound type. |
void |
setIncludeDrm(boolean includeDrm)
Sets whether to include DRM ringtones. |
void |
setStopPreviousRingtone(boolean stopPreviousRingtone)
Whether retrieving another Ringtone will stop playing the
previously retrieved Ringtone. |
void |
setType(int type)
Sets which type(s) of ringtones will be listed by this. |
void |
stopPreviousRingtone()
Stops playing the last Ringtone retrieved from this. |
| Methods inherited from class java.lang.Object |
|---|
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait |
| Field Detail |
|---|
public static final int TYPE_RINGTONE
public static final int TYPE_NOTIFICATION
public static final int TYPE_ALARM
public static final int TYPE_ALL
public static final String ACTION_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,
EXTRA_RINGTONE_INCLUDE_DRM.
Output: EXTRA_RINGTONE_PICKED_URI.
public static final String EXTRA_RINGTONE_SHOW_DEFAULT
ACTION_RINGTONE_PICKER,
Constant Field Valuespublic static final String EXTRA_RINGTONE_SHOW_SILENT
EXTRA_RINGTONE_PICKED_URI will be null.
ACTION_RINGTONE_PICKER,
Constant Field Valuespublic static final String EXTRA_RINGTONE_INCLUDE_DRM
public static final String EXTRA_RINGTONE_EXISTING_URI
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
Settings.System.DEFAULT_RINGTONE_URI or
Settings.System.DEFAULT_NOTIFICATION_URI to have the "Default" item
checked.
ACTION_RINGTONE_PICKER,
Constant Field Valuespublic static final String EXTRA_RINGTONE_DEFAULT_URI
Uri. The Uri of the
ringtone to play when the user attempts to preview the "Default"
ringtone. This can be one of Settings.System.DEFAULT_RINGTONE_URI or
Settings.System.DEFAULT_NOTIFICATION_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.
public static final String EXTRA_RINGTONE_TYPE
TYPE_RINGTONE,
TYPE_NOTIFICATION, TYPE_ALARM, or TYPE_ALL
(bitwise-ored together).
public static final String EXTRA_RINGTONE_TITLE
CharSequence. The title to
show for the ringtone picker. This has a default value that is suitable
in most cases.
public static final String EXTRA_RINGTONE_PICKED_URI
Uri.
It will be one of:
Uri that equals Settings.System.DEFAULT_RINGTONE_URI or
Settings.System.DEFAULT_NOTIFICATION_URI if the default was chosen,
ACTION_RINGTONE_PICKER,
Constant Field Valuespublic static final int ID_COLUMN_INDEX
getCursor() for the
row ID.
public static final int TITLE_COLUMN_INDEX
getCursor() for the
title.
public static final int URI_COLUMN_INDEX
getCursor() for the
media provider's URI.
| Constructor Detail |
|---|
public RingtoneManager(Activity activity)
activity - The activity used to get a managed cursor.public RingtoneManager(Context context)
context - The context to used to get a cursor.| Method Detail |
|---|
public void setType(int type)
type - The type(s), one or more of TYPE_RINGTONE,
TYPE_NOTIFICATION, TYPE_ALARM,
TYPE_ALL.EXTRA_RINGTONE_TYPEpublic void setStopPreviousRingtone(boolean stopPreviousRingtone)
Ringtone will stop playing the
previously retrieved Ringtone.
If this is false, make sure to Ringtone.stop() any previous
ringtones to free resources.
stopPreviousRingtone - If true, the previously retrieved
Ringtone will be stopped.public boolean getStopPreviousRingtone()
setStopPreviousRingtone(boolean)public void stopPreviousRingtone()
Ringtone retrieved from this.
public boolean getIncludeDrm()
setIncludeDrm(boolean)public void setIncludeDrm(boolean includeDrm)
includeDrm - Whether to include DRM ringtones.public Cursor getCursor()
Cursor of all the ringtones available. The returned
cursor will be the same cursor returned each time this method is called,
so do not Cursor.close() the cursor. The cursor can be
Cursor.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.ID_COLUMN_INDEX,
TITLE_COLUMN_INDEX,
URI_COLUMN_INDEXpublic Ringtone getRingtone(int position)
Ringtone for the ringtone at the given position in the
Cursor.
position - The position (in the Cursor) of the ringtone.
Ringtone pointing to the ringtone.public Uri getRingtoneUri(int position)
Uri for the ringtone at the given position in the Cursor.
position - The position (in the Cursor) of the ringtone.
Uri pointing to the ringtone.public int getRingtonePosition(Uri ringtoneUri)
Uri within this RingtoneManager.
ringtoneUri - The Uri to retreive the position of.
Uri, or -1 if it cannot be found.public static Uri getValidRingtoneUri(Context context)
context - The context to use for querying.
public static Ringtone getRingtone(Context context,
Uri ringtoneUri)
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.
public static Uri getActualDefaultRingtoneUri(Context context,
int type)
Uri. This will give the actual
sound Uri, instead of using this, most clients can use
Settings.System.DEFAULT_RINGTONE_URI.
context - A context used for querying.type - The type whose default sound should be returned. One of
TYPE_RINGTONE or TYPE_NOTIFICATION.
Uri pointing to the default sound for the sound type.setActualDefaultRingtoneUri(Context, int, Uri)
public static void setActualDefaultRingtoneUri(Context context,
int type,
Uri ringtoneUri)
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 or TYPE_NOTIFICATION.ringtoneUri - A Uri pointing to the default sound to set.getActualDefaultRingtoneUri(Context, int)public static boolean isDefault(Uri ringtoneUri)
Uri is one of the default ringtones.
ringtoneUri - The ringtone Uri to be checked.
Uri is a default.public static int getDefaultType(Uri defaultRingtoneUri)
Uri.
defaultRingtoneUri - The default Uri. For example,
Settings.System.DEFAULT_RINGTONE_URI or
Settings.System.DEFAULT_NOTIFICATION_URI.
public static Uri getDefaultUri(int type)
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.
|
Build 1.0_r1(from source) | |||||||||
| PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||||
| SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD | |||||||||