本文介绍了安卓:GET调用接触史的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!
问题描述
我用这code中的得到联系人的联络信息(我用它也 - 有一些修改 - 打电话,发短信或邮件中的联系)。我不知道是否有一种方式来表现出一定的联系的通话记录:
字符串NAME3是联系人姓名。
contactinfobtn.setOnClickListener(新View.OnClickListener()
{
公共无效的onClick(视图v)
{
ContentResolver的CR = getContentResolver();
光标CUR = cr.query(ContactsContract.Contacts.CONTENT_URI,NULL,NULL,NULL,NULL);
如果(cur.getCount()大于0)
{
而(cur.moveToNext()){
id_contact = cur.getString(cur.getColumnIndex(ContactsContract.Contacts._ID));
name_contact = cur.getString(cur.getColumnIndex(ContactsContract.Contacts.DISPLAY_NAME));
如果(name_contact.equals(NAME3))
{
光标pCur = cr.query(
ContactsContract.CommonDataKinds.Phone.CONTENT_URI,空,
ContactsContract.CommonDataKinds.Phone.CONTACT_ID +=,新的String [] {} id_contact,NULL);
id_contact2 = id_contact;
而(pCur.moveToNext()){
}
pCur.close();
}
}
意图intent_contacts =新的意图(Intent.ACTION_VIEW,Uri.parse(内容://联系人/人/+ id_contact2));
startActivity(intent_contacts);
}
}
});
解决方案
有一类叫的的包含 CONTENT_URI 来查询通话记录。
下面是一个例子,列出的电话号码在通话记录:
@覆盖
公共无效的onCreate(包savedInstanceState){
super.onCreate(savedInstanceState);
this.setContentView(R.layout.main);
的String []投影=新的String [] {
CallLog.Calls._ID,CallLog.Calls.NUMBER};
光标查询= this.managedQuery(
CallLog.Calls.CONTENT_URI,投影,NULL,NULL,NULL);
ListAdapter适配器=新SimpleCursorAdapter(
此,android.R.layout.simple_list_item_1,查询,
新的String [] {} CallLog.Calls.NUMBER,
新的INT [] {android.R.id.text1});
this.setListAdapter(适配器);
}
i am using this code the get to the contact info of a contact (i am using it also - with a few modifications - to call, send sms or email the contact). I wonder if there is a way to show the call history of a certain contact:
String name3 is the contact name.
contactinfobtn.setOnClickListener(new View.OnClickListener()
{
public void onClick(View v)
{
ContentResolver cr = getContentResolver();
Cursor cur = cr.query(ContactsContract.Contacts.CONTENT_URI, null, null, null, null);
if (cur.getCount() > 0)
{
while (cur.moveToNext()) {
id_contact = cur.getString(cur.getColumnIndex(ContactsContract.Contacts._ID));
name_contact = cur.getString(cur.getColumnIndex(ContactsContract.Contacts.DISPLAY_NAME));
if (name_contact.equals(name3))
{
Cursor pCur = cr.query(
ContactsContract.CommonDataKinds.Phone.CONTENT_URI, null,
ContactsContract.CommonDataKinds.Phone.CONTACT_ID +" = ?", new String[]{id_contact}, null);
id_contact2 = id_contact;
while (pCur.moveToNext()){
}
pCur.close();
}
}
Intent intent_contacts = new Intent(Intent.ACTION_VIEW, Uri.parse("content://contacts/people/" + id_contact2));
startActivity(intent_contacts);
}
}
});
解决方案
There is a class called CallLog.Calls that contains the CONTENT_URI to query for call history.
Here's an example listing the phone numbers in the call log:
@Override
public void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
this.setContentView(R.layout.main);
String[] projection = new String[] {
CallLog.Calls._ID, CallLog.Calls.NUMBER};
Cursor query = this.managedQuery(
CallLog.Calls.CONTENT_URI, projection, null, null, null);
ListAdapter adapter = new SimpleCursorAdapter(
this, android.R.layout.simple_list_item_1, query,
new String[] {CallLog.Calls.NUMBER},
new int[] {android.R.id.text1});
this.setListAdapter(adapter);
}
这篇关于安卓:GET调用接触史的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持!