phonecalls - Get call receive event in android -
can incoming call pick , end call event in android through coding? want when received incoming call should show toast message. incoming call want when end call should show toast message in app.please suggest me.
if want when application's 1 activity use following code :
phonestatelistener phonestatelistener = new phonestatelistener() { @override public void oncallstatechanged(int state, string incomingnumber) { if (state == telephonymanager.call_state_ringing) { // incoming call: pause music log.i("phone", "ringing"); } else if (state == telephonymanager.call_state_idle) { log.i("phone", "idle"); } else if (state == telephonymanager.call_state_offhook) { // call dialing, active or on hold log.i("phone", "offhook"); } super.oncallstatechanged(state, incomingnumber); } };
or if want show toast eve outside of application try make service
.
there nice tutorials on service available.
first read this on developer.
and tutorial.
Comments
Post a Comment