【问题标题】:Putting contact info into Phone Book from Blackberry从 Blackberry 将联系信息放入电话簿
【发布时间】:2012-05-01 04:46:37
【问题描述】:

在我的应用程序中,我需要将我的应用程序中的联系信息添加到 BlackBerry 的电话簿中。 我怎样才能实现它?

我参考了Java开发指南"Create a contact and assign it to a contact list"

【问题讨论】:

    标签: blackberry contact addressbook


    【解决方案1】:

    查看Contact documentation了解更多信息

    【讨论】:

      【解决方案2】:

      创建一个联系人,每次你必须检查它是否支持该字段

      ContactList contacts = null;
       try {
           contacts = (ContactList) PIM.getInstance().openPIMList( PIM.CONTACT_LIST,
                   PIM.READ_WRITE );
       } catch( PIMException e ) {
           // An error occurred
           return;
       }
       Contact contact = contacts.createContact();
      
       String[] name = new String[ contacts.stringArraySize( Contact.NAME ) ];
       name[ Contact.NAME_GIVEN ] = "John";
       name[ Contact.NAME_FAMILY ] = "Public";
      
       String[] addr = new String[ contacts.stringArraySize( Contact.ADDR ) ];
       addr[ Contact.ADDR_COUNTRY ] = "USA";
       addr[ Contact.ADDR_LOCALITY ] = "Coolsville";
       addr[ Contact.ADDR_POSTALCODE ] = "91921-1234";
       addr[ Contact.ADDR_STREET ] = "123 Main Street";
      
       try {
           contact.addString( Contact.NAME_FORMATTED, PIMItem.ATTR_NONE,
                   "Mr. John Q. Public, Esq." );
           contact.addStringArray( Contact.NAME, PIMItem.ATTR_NONE, name );
           contact.addStringArray( Contact.ADDR, Contact.ATTR_HOME, addr );
           contact.addString( Contact.TEL, Contact.ATTR_HOME, "613-123-4567" );
           contact.addToCategory( "Friends" );
           contact.addDate( Contact.BIRTHDAY, PIMItem.ATTR_NONE, new Date().getTime() );
           contact.addString( Contact.EMAIL, Contact.ATTR_HOME
                   | Contact.ATTR_PREFERRED, "jqpublic@xyz.dom1.com" );
      
       } catch( UnsupportedFieldException e ) {
           // In this case, we choose not to save the contact at all if any of the
           // fields are not supported on this platform.
           System.out.println( "Contact not saved" );
           return;
       }
      
       try {
           contact.commit();
       } catch( PIMException e ) {
           // An error occured
       }
       try {
           contacts.close();
       } catch( PIMException e ) {
       }
      

      【讨论】:

        猜你喜欢
        • 1970-01-01
        • 1970-01-01
        • 1970-01-01
        • 1970-01-01
        • 1970-01-01
        • 1970-01-01
        • 2020-01-17
        • 2014-02-09
        • 1970-01-01
        相关资源
        最近更新 更多