android - 如何检测来电 [英] android - How detect incoming call

查看:74
本文介绍了android - 如何检测来电的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述





我的Android应用程序如何检测来电,然后如何搜索电话联系人列表以查找来电联系是否存在?

我想使用android API进行此操作..



谢谢。

解决方案

1。使用

 onCallStateChanged(int state,String incomingNumber)

获取传入的电话号码。请参阅http://developer.android.com/reference/android/telephony/PhoneStateListener.html [ ^ ]



2.查询联系人数据库中的电话号码。

 mContext.getContentResolver()。query(Contacts.CONTENT_URI, new   String  [] {ContactsContract.CommonDataKinds.Phone.NUMBER}, null  null  null ); 





参考

http://developer.android.com/reference/android/provider/ContactsContract。 CommonDataKinds.Phone.html [ ^ ]


Hi,

How my android app can detect for incoming call and then how can search in phone contact list to find if the incoming contact exists?
I want to use android API for this operations..

Thanks.

解决方案

1. use

onCallStateChanged(int state, String incomingNumber)

to get incoming phone number.refer to http://developer.android.com/reference/android/telephony/PhoneStateListener.html[^]

2. query phone number in contact database.

mContext.getContentResolver().query(Contacts.CONTENT_URI, new String[]{ContactsContract.CommonDataKinds.Phone.NUMBER},null, null, null);



refer to
http://developer.android.com/reference/android/provider/ContactsContract.CommonDataKinds.Phone.html[^]


这篇关于android - 如何检测来电的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆