On Android, I'm having a problem trying to figure out which ringtone is actually playing (I'm not trying to detect the default ringtone, but the one actually playing as it may be different due to user setting a particular ringtone for a particular contact).
I'm using the Ringtone.isPlaying() function as I cycle through (successfully) all the available Ringtones from the RingtoneManager. However none of them ever returns true to Ringtone.isPlaying()! Anyone have a clue what I am doing wrong? Here is the code sample that is definitely being run whilst the ring is playing:
RingtoneManager rm = new RingtoneManager(this); // 'this' is my activity (actually a Service in my case)
if (rm != null)
{
Cursor cursor = rm.getCursor();
cursor.moveToFirst();
for (int i = 0; ; i++)
{
Ringtone ringtone = rm.getRingtone(i); // get the ring tone at this position in the Cursor
if (ringtone == null)
break;
else if (ringtone.isPlaying() == true)
return (ringtone.getTitle(this)); // *should* return title of the playing ringtone
}
return "FAILED AGAIN!"; // always ends up here
}