android - 如何检测来电 [英] android - How detect incoming call
问题描述
我的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. useonCallStateChanged(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屋!