get调用Android中接收事件 [英] Get call receive event in android
本文介绍了get调用Android中接收事件的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!
问题描述
我能否获得来电通过编码拿起和结束呼叫事件在android系统?我想,当我收到来电那么应该显示敬酒消息。像来电我想,当我们结束呼叫话应该显示敬酒消息在我app.please建议我。
Can I get incoming call pick up and end call event in android through coding? I want to that when I received incoming call then should be show toast message. Like incoming call I want to that when we end call then should be show toast message in my app.please suggest me.
推荐答案
如果你想让它,只有当你的应用程序的一个活动,然后使用以下code:
If you want it to only when your application's one activity then 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) {
// A call is dialing, active or on hold
Log.i("Phone", "offhook");
}
super.onCallStateChanged(state, incomingNumber);
}
};
或者,如果你想显示你的应用程序之外敬酒前夕然后尽量让服务
。
有上提供的服务一些不错的教程。
There are some nice tutorials on service available.
首先阅读这的开发商。
和也看看这个教程。
这篇关于get调用Android中接收事件的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!
查看全文