【问题标题】:blackberry list contacts with email address黑莓列表联系人与电子邮件地址
【发布时间】:2011-11-10 19:45:24
【问题描述】:

我正在使用此代码 sn-p 检索联系人的电子邮件地址,但我想做的是列出拥有电子邮件地址的联系人。使用此方法,它会显示所有联系人

try {
                list = (BlackBerryContactList) PIM.getInstance()
                .openPIMList(PIM.CONTACT_LIST, PIM.READ_ONLY);

                PIMItem contact = list.choose();
                if (contact != null) {
                    String emailId = "";

                    for (int i = 0; i < contact.countValues(Contact.EMAIL); i++) {
                        emailId = contact.getString(Contact.EMAIL, i);
                        System.out.println("_ _ _  _ __  EMAIL : " + i + " " +  emailId);
                    }
                }
            } catch (PIMException e) {
                Dialog.inform("Proble creating contact list!");
                e.printStackTrace();
            }

【问题讨论】:

    标签: email blackberry contacts


    【解决方案1】:

    在函数下方找到只返回包含电子邮件地址的联系人列表:

    /*import email id from the contact list. */
    
    public Vector getEmail()
    {
    
        Vector emailList=new Vector();//contains the list of contact
        email_list.removeAllElements();
        try
        {
            PIM pim = PIM.getInstance();
            ContactList contacts;
            contacts = (ContactList) pim.openPIMList(PIM.CONTACT_LIST, PIM.READ_ONLY);
            Enumeration items;
            items = contacts.items();
    
            while(items.hasMoreElements())
            {
                Contact contact = (Contact) items.nextElement();
    
                String emailID = "";
                if (contacts.isSupportedField(Contact.EMAIL) && (contact.countValues(Contact.EMAIL) > 0) ) 
                {   
                     emailID=contact.getString(Contact.EMAIL, 0);
    
                    //emailList.addElement(arr);
                }
                String firstName = "";
                if ((contacts.isSupportedField(Contact.NAME)) && (contact.countValues(Contact.NAME) > 0))
                {
                    String[] name = contact.getStringArray(Contact.NAME, 0);
                    firstName = name[Contact.NAME_GIVEN];
                  //  String lastName = name[Contact.NAME_FAMILY];
                }
                String arr[]={emailID,firstName};//array which contains emailid and first name
                emailList.addElement(arr);
    
            }
        }
        catch(Exception pe)
        {
        }
        return emailList;
    }
    

    【讨论】:

    • 这是一个很好的解决方案,但是否可以将一些参数传递给联系人应用程序并获得所需的结果?
    • 上述方法返回具有电子邮件ID的所有联系人列表。现在您可以根据您的要求修改上述代码。顺便说一句,你想要什么类型的结果。请描述
    • 我知道如何通过电子邮件检索联系人。我希望内置的联系人应用程序列出带有电子邮件的联系人。有可能吗?
    • 这里相信股票联系人应用程序无法列出带有电子邮件的联系人,但 Vivek 的回答适合标记它。
    猜你喜欢
    • 1970-01-01
    • 1970-01-01
    • 2010-12-05
    • 2012-08-15
    • 1970-01-01
    • 1970-01-01
    • 2018-11-14
    • 1970-01-01
    • 2012-06-24
    相关资源
    最近更新 更多