I need to know is it possible to play a particular audio file from android in-built ringtone files. For example assume Tone_23 is in android ringtone list, now i need to play this particular tone, when i click a button. I searched in Google i got a guidance how to call/show RingtonePicker Activity (The entire Ringtone list will be displayed). If this possible means, kindly share your thoughts. Thanks in advance.
You can try some thing like this :
/**
* Play ring tone.
*
* @param ringToneTitle the ring tone title
*/
void playRingTone(String ringToneTitle) {
RingtoneManager ringtoneManager = new RingtoneManager(
getApplicationContext());
ringtoneManager.setType(RingtoneManager.TYPE_RINGTONE);
int length = ringtoneManager.getCursor().getCount();
for (int i = 0; i < length; i++) {
Ringtone mRingtone = ringtoneManager.getRingtone(i);
if (mRingtone != null) {
Log.d("ringtoneTitle ", mRingtone.getTitle(getApplicationContext()));
if(ringToneTitle.equalsIgnoreCase(mRingtone
.getTitle(getApplicationContext())) {
mRingtone.play();
}
}
}
}
Hope this helps.
Added : Also have a look at this 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.