Welcome!

Welcome to the official BlackBerry Support Community Forums.

This is your resource to discuss support topics with your peers, and learn from each other.

inside custom component

Java Development


Thank you for visiting the BlackBerry Support Community Forums.

BlackBerry will be closing the BlackBerry Support Community Forums Device Forums on April 1st (Developers, see below)

BlackBerry remains committed to providing excellent customer support to our customers. We are delighted to direct you to the CrackBerry Forums, a well-established and thorough support channel, for continued BlackBerry support. Please visit http://forums.crackberry.com or http://crackberry.com/ask. You can also continue to visit BlackBerry Support or the BlackBerry Knowledge Base for official support options available for your BlackBerry Smartphone.

"When we launched CrackBerry.com 10 years ago, we set out to make it a fun and useful destination where BlackBerry Smartphone owners could share their excitement and learn to unleash the full potential of their BlackBerry. A decade later, the CrackBerry community is as active and passionate as ever and I know our knowledgeable members and volunteers will be excited to welcome and assist more BlackBerry owners with their questions."

- Kevin Michaluk, Founder, CrackBerry.com

Developers, for more information about the BlackBerry Developer Community please review Join the Conversation on the BlackBerry Developer Community Forums found on Inside BlackBerry.


Reply
Highlighted
Developer
Posts: 17,026
Registered: ‎07-29-2008
My Device: Z10 LE, Z30, Passport
My Carrier: O2 Germany
Accepted Solution

Read and display the photo of a addressbook contact

i want to display the photo of a contact. i have set one of the sample pictures on the simulator.

byte[] b = blackberryContact.getBinary(BlackBerryContact.PHOTO, 0);
System.out.println("b lenght: " + b.length);
EncodedImage e = EncodedImage.createEncodedImage(b, 0, b.length);
BitmapField bf = new BitmapField();
bf.setImage(e);

i get the output
b lenght: 3556
followed by an IllegalArgumentException, according to API: If the image format is not recognized, an IllegalArgumentException is thrown.

How do i get the byte[] from the BlackBerryContact to the correct format to be used with createEncodedImage ?
----------------------------------------------------------
feel free to press the like button on the right side to thank the user that helped you.
please mark posts as solved if you found a solution.
@SimonHain on twitter
BlackBerry Development Advisor
Posts: 15,889
Registered: ‎07-09-2008
My Device: BlackBerry PRIV
My Carrier: Bell

Re: Read and display the photo of a addressbook contact

This is caused by an issue with the BlackBerry handheld software and has been fixed in version 4.5.0.
Mark Sohm
BlackBerry Development Advisor

Please refrain from posting new questions in solved threads.
Problem solved? Click the Accept As Solution button.
Developer
Posts: 17,026
Registered: ‎07-29-2008
My Device: Z10 LE, Z30, Passport
My Carrier: O2 Germany

Re: Read and display the photo of a addressbook contact

i use jde 4.6.0.12 and the bold simulator that is part of the package. is there a newer version available?
----------------------------------------------------------
feel free to press the like button on the right side to thank the user that helped you.
please mark posts as solved if you found a solution.
@SimonHain on twitter
BlackBerry Development Advisor
Posts: 15,889
Registered: ‎07-09-2008
My Device: BlackBerry PRIV
My Carrier: Bell

Re: Read and display the photo of a addressbook contact

The photo is stored in base64 format, which your code is not handling.  Have a look at the JavaDocs for the javax.microedition.pim.Contact class for an example.  Sorry for not catching that the first time. 

 

This should also work on previous versions.  The issue I thought this related to only applies when saving a contact.

Mark Sohm
BlackBerry Development Advisor

Please refrain from posting new questions in solved threads.
Problem solved? Click the Accept As Solution button.
Developer
Posts: 17,026
Registered: ‎07-29-2008
My Device: Z10 LE, Z30, Passport
My Carrier: O2 Germany

Re: Read and display the photo of a addressbook contact

thanks, that solved it. if i have looked at the 4.5/4.6 api instead of the old 4.2.1 one i would have seen it myself.
----------------------------------------------------------
feel free to press the like button on the right side to thank the user that helped you.
please mark posts as solved if you found a solution.
@SimonHain on twitter