开发者

Reading Contact List in Micromax Q50

I am using the following code to r开发者_如何学JAVAead Contact List in Micromax Device. But without any success.

try {
        PIM t_pim = PIM.getInstance();

        String[] namesOfContactLists = t_pim.listPIMLists(PIM.CONTACT_LIST);

        PIMList t_pimlist = t_pim.openPIMList(PIM.CONTACT_LIST, PIM.READ_ONLY, namesOfContactLists[0]);//namesOfContactLists[0] is the Phone List.

        Enumeration t_enumeration = t_pimlist.items();

        boolean isFormattedNameSupported = t_pimlist.isSupportedField(Contact.FORMATTED_NAME);

        while (t_enumeration.hasMoreElements()) {

            String t_contactName = "";

            Contact t_contact = (Contact) t_enumeration.nextElement();

            if (isFormattedNameSupported) {

                if (t_contact.countValues(Contact.FORMATTED_NAME) > 0) {

                    t_contactName = t_contact.getString(Contact.FORMATTED_NAME, 0);//Throws UnsupportedFieldException

                }

            }

        }
    } catch (PIMException ex) {
        ex.printStackTrace();
    }

Other options like Contact.NAME, Contact.NAME_GIVEN, Contact.NAME_FAMILY, Contact.NAME_OTHER, Contact.NAME_PREFIX, Contact.NAME_SUFFIX, Contact.NICKNAME also throw the same UnsupportedFieldException.

This code works fine on Nokia and Sony Ericsson devices. But fails on Micromax.


When you say "without any success", what do you mean? What actually happens? If you mean that FORMATTED_NAME is an unsupported field for Contact, then these fields are optional. Use PIMList.getSupportedFields() to figure out which fields you can read on each platform.

0

上一篇:

下一篇:

精彩评论

暂无评论...
验证码 换一张
取 消

最新问答

问答排行榜