android - Retrieve the name of playing ringtone in PhoneStateListener -
essentially title says all. want able retrieve playing ringtone in phonestatelistener class. 1 solution might retrieve default uri ringtonemanager if there custom contact ringtone playing?
obligatory code snippets i've tried far. none of them homecoming ringtone. isplaying false.
public static string getplayingringtone() { ringtonemanager m = new ringtonemanager(mctx); cursor rings = m.getcursor(); for( int = 0; < rings.getcount(); i++ ) { ringtone tone = m.getringtone(i); if (tone.isplaying() ) log.d("playcallringtone", "**is playing**" + tone.gettitle(mctx)); } homecoming null; }
alternatively, i've tried:
log.d("playcallringtone", ringtonemanager.getringtone(mctx, ringtonemanager.getdefaulturi(ringtonemanager.type_ringtone)).gettitle(mctx) + " playing");
my phonestatelistener following:
private class myphonestatelistener extends phonestatelistener { public void oncallstatechanged(int state,string number){ switch(state){ case telephonymanager.call_state_idle: // stuff idle break; case telephonymanager.call_state_offhook: // stuff of offhook break; case telephonymanager.call_state_ringing: getplayingringtone(); // stuff ringing break; } } }
there property in contactscontract.contactoptionscolumns : public static final string custom_ringtone
has uri custom ringtone associated contact. if null or missing, default ringtone used. in phone state listener when u fetch number contact object , check custom_ringtone property. if null fetch default ringtone ringtonemanager
else can customized ringtone contact.
android broadcastreceiver android-cursoradapter ringtone phone-state-listener
No comments:
Post a Comment