从自定义列表的Andr​​oid获取电话簿的联系人详细信息页面 [英] Get Phonebook contacts Detail page from custom list android

查看:111
本文介绍了从自定义列表的Andr​​oid获取电话簿的联系人详细信息页面的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我已经在我得到的所有电话簿的联系人并显示在我自己的清单,自定义视图他们的自定义列表。我保存一个ArrayList的所有联系人(inculding接触ID)。当我点击列表我想把它打开了默认的Andr​​oid方式接触的所有细节。请能有人告诉我,如果这是可能的或没有。

我的code低于保存联系人在我自己的名单:

  ArrayList的=新的ArrayList< PhoneBookUserEntity>();
    光标光标= getContentResolver()查询(
            ContactsContract.Contacts.CONTENT_URI,NULL,NULL,NULL,Phone.DISPLAY_NAME +ASC);
    如果(cursor.getCount()大于0)
    {
        而(cursor.moveToNext())
        {            PhoneBookUserEntity用户=新PhoneBookUserEntity();
            //挑选出的ID和的显示名称
            //从光标的当前行接触
            user.setId(cursor.getString(cursor.getColumnIndex(BaseColumns._ID)));
            user.setPhoneBookName(cursor.getString(cursor.getColumnIndex(
                    ContactsContract.Contacts.DISPLAY_NAME)));            串hasPhone = cursor.getString(cursor.getColumnIndex(ContactsContract.Contacts.HAS_PHONE_NUMBER));
            //如果(Boolean.parseBoolean(hasPhone)){
            。光标手机= getContentResolver()查询(ContactsContract.CommonDataKinds.Phone.CONTENT_URI,空,ContactsContract.CommonDataKinds.Phone.CONTACT_ID +=+ user.getId(),NULL,NULL);
            而(phones.moveToNext()){
                user.sePhoneNumber(phones.getString(phones.getColumnIndex(ContactsContract.CommonDataKinds.Phone.NUMBER)));
            }
            phones.close();
            //}
            // user.sePhoneNumber(cursor.getString(cursor.getColumnIndex(ContactsContract.CommonDataKinds.Phone.NUMBER)));            。光标电子邮件= getContentResolver()查询(ContactsContract.CommonDataKinds.Email.CONTENT_URI,空,ContactsContract.CommonDataKinds.Email.CONTACT_ID +=+ user.getId(),NULL,NULL);
            而(emails.moveToNext()){
                //这将让你得到一些电子邮件地址
                user.setEmailAddress(emails.getString(emails.getColumnIndex(ContactsContract.CommonDataKinds.Email.DATA)));
            }
            emails.close();
            user.setImageURI(getPhotoUri(user.getId()));
            arraylist.add(用户);
            //做一些与你的价值观,
            //如打印出来,或添加到列表
            在这个迭代//System.out.println(\"Current接触是:+姓名);            //这是我们查询电子邮件,地址等
            //下面添加到片段在这里,这取决于你需要什么
        }    }
    cursor.close();


解决方案

试试这个

 意向意图=新意图(Intent.ACTION_VIEW);
URI URI = Uri.withAppendedPath(ContactsContract.Contacts.CONTENT_URI,将String.valueOf(的ContactID));
intent.setData(URI);
context.startActivity(意向);

这应该在Android开放触点卡

I have made a custom list in which I am getting all the phone book contacts and showing them in my own list with a custom view. I save all the contacts (inculding the contacts id) in an arraylist. When I click on a list I want it open all the details of that contact in the default android manner. Please can some one tell me if this is possible or not.

my code is below for saving the contacts in my own list:

arraylist = new ArrayList<PhoneBookUserEntity>();
    Cursor cursor = getContentResolver().query(
            ContactsContract.Contacts.CONTENT_URI, null, null, null, Phone.DISPLAY_NAME + " ASC");
    if (cursor.getCount() > 0)
    {
        while (cursor.moveToNext())
        {

            PhoneBookUserEntity user = new PhoneBookUserEntity();
            // Pick out the ID, and the Display name of the
            // contact from the current row of the cursor
            user.setId(cursor.getString(cursor.getColumnIndex(BaseColumns._ID)));
            user.setPhoneBookName(cursor.getString(cursor.getColumnIndex(
                    ContactsContract.Contacts.DISPLAY_NAME)));

            String hasPhone = cursor.getString(cursor.getColumnIndex(ContactsContract.Contacts.HAS_PHONE_NUMBER)); 
            //    if (Boolean.parseBoolean(hasPhone)) { 
            Cursor phones = getContentResolver().query( ContactsContract.CommonDataKinds.Phone.CONTENT_URI, null, ContactsContract.CommonDataKinds.Phone.CONTACT_ID +" = "+ user.getId(), null, null); 
            while (phones.moveToNext()) { 
                user.sePhoneNumber(phones.getString(phones.getColumnIndex( ContactsContract.CommonDataKinds.Phone.NUMBER)));                 
            } 
            phones.close(); 
            //}
            // user.sePhoneNumber(cursor.getString(cursor.getColumnIndex(ContactsContract.CommonDataKinds.Phone.NUMBER))); 

            Cursor emails = getContentResolver().query(ContactsContract.CommonDataKinds.Email.CONTENT_URI, null, ContactsContract.CommonDataKinds.Email.CONTACT_ID + " = " + user.getId(), null, null); 
            while (emails.moveToNext()) { 
                // This would allow you get several email addresses 
                user.setEmailAddress(emails.getString(emails.getColumnIndex(ContactsContract.CommonDataKinds.Email.DATA))); 
            } 
            emails.close(); 
            user.setImageURI(getPhotoUri(user.getId()));
            arraylist.add(user);
            // Do something with the values you have,
            // such as print them out or add to a list
            //System.out.println("Current contact on this iteration is : " + name);

            // This is where we query for Emails, Addresses etc
            // Add snippets below into here, depending on what you need
        }

    }
    cursor.close();

解决方案

Try this

Intent intent = new Intent(Intent.ACTION_VIEW);
Uri uri = Uri.withAppendedPath(ContactsContract.Contacts.CONTENT_URI, String.valueOf(contactID));
intent.setData(uri);
context.startActivity(intent);

This should open the contacts card in android

这篇关于从自定义列表的Andr​​oid获取电话簿的联系人详细信息页面的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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