telephonymanager - Android Handle phone call -
i have audio recording, when phone call come need stop recording, how can this?
you have use phonestatelistener
:
telephonymanager tm = (telephonymanager)getsystemservice(telephony_service); tm.listen(mphonelistener, phonestatelistener.listen_call_state); // somewhere else private phonestatelistener mphonelistener = new phonestatelistener() { public void oncallstatechanged(int state, string incomingnumber) { try { switch (state) { case telephonymanager.call_state_ringing: // something... break; case telephonymanager.call_state_offhook: // something... break; case telephonymanager.call_state_idle: // something... break; default: log.d(tag, "unknown phone state=" + state); } } catch (remoteexception e) {} } };
make sure include permission in manifest:
<uses-permission android:name="android.permission.read_phone_state"/>
Comments
Post a Comment