×

Discussion Board

Results 1 to 8 of 8
  1. #1
    Registered User
    Join Date
    Mar 2003
    Location
    Israel
    Posts
    4

    Reading vCards with the PIM API (JSR 75)

    Hi,

    I am trying to read a vCard through the PIM API (JSR 75):

    void addContact(String vCard) {

    PIMItem[] items = PIM.getInstance().fromSerialFormat(
    new ByteArrayInputStream(vCard.getBytes()), "UTF-8");
    if (items != null && items.length > 0) {
    Contact c = (Contact) (items[0]);
    ...
    }
    }

    However, when I try to run it on Nokia 6630, I get a Null Pointer Exception from the first line. I verified that the vCard parameter is not null and valid.

    Any idea what could be the cause for that?

    Thanks,
    Yoad

  2. #2
    Super Contributor
    Join Date
    Dec 2005
    Location
    Europe/Poland/Warsaw
    Posts
    1,697

    Re: Reading vCards with the PIM API (JSR 75)

    hi Yoad,

    I have an idea how you can test that (if it works at all on your device),
    because "fromSerialFormat" is accompanied with "toSerialFormat" you could probably write test case for your device, that is read contact, write it and then recreate it, that way check if api is working fine on that device,

    regards,
    Peter

  3. #3
    Registered User
    Join Date
    Dec 2005
    Location
    Brazil
    Posts
    1,884

    Re: Reading vCards with the PIM API (JSR 75)

    Hi Yoad,

    If you're sure you're talking about Nokia 6630 (and not 6630i), it doesn't support JSR-75. See the specs for Nokia 6630 - http://www.forum.nokia.com/devices/6230

    There's no support to PIM API on Nokia 6630, unfortunately.

    Hope it helps

    BR,

    Juarez Junior

  4. #4
    Registered User
    Join Date
    Mar 2003
    Location
    Israel
    Posts
    4

    Re: Reading vCards with the PIM API (JSR 75)

    Hi Juarez,

    I am talking about Nokia 6630, which supports JSR-75:
    http://www.forum.nokia.com/devices/6630

    The link that you provided is for Nokia 6230.

    Thanks,
    Yoad

  5. #5
    Registered User
    Join Date
    Dec 2005
    Location
    Brazil
    Posts
    1,884

    Re: Reading vCards with the PIM API (JSR 75)

    Hi Yoad,

    Yes, i've read it wrong, forgive this misundertanding. Yesterday was a busy day and I was tired then...

    "I get a Null Pointer Exception from the first line"

    Well, based on your report it seems that PIM.getInstance() is returning null some how.

    Also try to confirm API availability by using System.getProperty("microedition.pim.version") and make sure everything is OK.

    BR,

    Juarez Junior

  6. #6
    Registered User
    Join Date
    Mar 2003
    Location
    Israel
    Posts
    4

    Re: Reading vCards with the PIM API (JSR 75)

    Hi,

    I solved this problem. The Null Pointer Exception was because of an empty line at the beginning of the vCard. It seems like a bug in the implementation of JSR 75 on this platform.

    When I removed the empty line, I encountered another problem with the vCard format. I was trying to parse a vCard that I received through the network form a Windows server. The problem was that the vCard lines ended with a LF ('\n'), while the Nokia implementation expects a CRLF ('\r\n').

    Thanks,
    Yoad

  7. #7
    Registered User
    Join Date
    Dec 2005
    Location
    Brazil
    Posts
    1,884

    Re: Reading vCards with the PIM API (JSR 75)

    Hi Yoad,

    Thanks for sharing this info. Also, I am glad you managed to solve the problem.

    BR,

    Juarez Junior

  8. #8
    Super Contributor
    Join Date
    Dec 2005
    Location
    Europe/Poland/Warsaw
    Posts
    1,697

    Re: Reading vCards with the PIM API (JSR 75)

    hi guys,
    I've looked into vCard specs linked in Nokia docs as implemtation:
    http://www.imc.org/pdi/vcard-21.txt
    and it uses CRLF, eg:
    The paradigm of an electronic business card is related to the concepts of aQuoted-Printable lines of text must also be limited to less than 76 characters. The 76 characters does not include the CRLF (RFC 822) line break sequence. For example a multiple line LABEL property value of:
    123 Winding Way
    Any Town, CA 12345
    USA
    Would be represented in a Quoted-Printable encoding as:
    LABEL;ENCODING=QUOTED-PRINTABLE:123 Winding Way=0D=0A=
    Any Town, CA 12345=0D=0A=
    USA
    Code:
    All literal property names are valid as upper, lower, or mixed case.
    ws		= 1*(SPACE / HTAB)
    	; "whitespace," one or more spaces or tabs
    wsls		= 1*(SPACE / HTAB / CRLF)
    	; whitespace with line separators
    word		= <any printable 7bit us-ascii except []=:., >
    groups		= groups "." word
    		/ word
    vcard_file	= [wsls] vcard [wsls]
    vcard		= "BEGIN" [ws] ":" [ws] "VCARD" [ws] 1*CRLF
    		 items *CRLF "END" [ws] ":" [ws] "VCARD"
    items		= items *CRLF item
    		/ item
    	; these may be "folded"
    item		= [groups "."] name
    		  [params] ":" value CRLF
    		/ [groups "."] "ADR"
    		  [params] ":" addressparts CRLF
    		/ [groups "."] "ORG"
    		  [params] ":" orgparts CRLF
    		/ [groups "."] "N"
    		  [params] ":" nameparts CRLF
    		/ [groups "."] "AGENT"
    		  [params] ":" vcard CRLF
    I was trying to parse a vCard that I received through the network form a Windows server.
    it rather sounds (because of using LF - "\n") that orignally vCard was created on Unix-based machine not on windows machine (which uses CRLF by default), can it be the reason?

    regards,
    Peter

Similar Threads

  1. PC Suite error: (Code: Init IMediaControl2) HELP?!
    By chunkyspudmonkey in forum General Development Questions
    Replies: 30
    Last Post: 2014-07-15, 05:44
  2. How to avoid Nokia 9500/9300 security prompts while updating PIM data JSR 75?
    By cwietom in forum Mobile Java Networking & Messaging & Security
    Replies: 2
    Last Post: 2008-07-02, 17:11
  3. Replies: 0
    Last Post: 2006-02-24, 11:44
  4. load vCalendar file by PIM API
    By timony in forum Mobile Java Tools & SDKs
    Replies: 0
    Last Post: 2005-10-14, 12:03
  5. PIM API 和FILECONNECTION API 范例下载
    By dennisdeng in forum [Archived] Other Programming Discussion 关于其他编程技术的讨论
    Replies: 2
    Last Post: 2005-09-13, 08:41

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •  
×