Good Day to all,
I need help on how to display the photo of a phone contact/Contact object of the PIM API under the S40 3rd Edition (initial release, before Feature Pack 1). I am making a MIDlet that needs to display the photo contained within a contact inside the said program. It is similar to the Phone's view contact details in its function.
The problem is that the photo is not included in the supported Fields when I check the ContactList object thus cannot be read inside the java program. However, if I used the S40 5th edition as a platform (using exactly the same code), the photo is available and can be read inside the program.
Also, when importing a vcard using the "fromSerialFormat" and committing the receive contact, the contact is saved with its photo intact (S40 3rd Edition initial release, before Feature Pack 1 was used here); exporting vcard is also perfectly working on exporting its photo. Thus technically the S40 3rd edition initial release could read the photo. With that said, How am I able to read the photo inside the java program(if it is a limitation, are there any workaround?). I really need to make it work for a s40 3rd edition initial release platform so as to support more phones
Any help would be greatly appreciated. Thank you very much.
Here is the code snippet that displays the contact details:
"ContactContent" is a class that parses the Contact to extract the given name, last name, and tel number of a contact
"ContactPic" is an instance of javax.microedition.lcdui.ImageItem object found in netbeans
Code:public void fillContactInfo(int nSelected) { try { Contact c = (Contact) CurrentContactsList.elementAt(nSelected); int[] dataFields = c.getFields(); for (int i = 0; i < dataFields.length; i++) { switch (dataFields[i]) { case Contact.NAME: ContactContent contact = new ContactContent(); contact.setValues(c); NameDisplayModel.setValue(1, 0, contact.strFirstName); NameDisplayModel.setValue(1, 1, contact.strLastName); NameDisplayModel.fireTableModelChanged(); // NameDisplayModel. break; case Contact.TEL: String[][] strNos = new String[c.countValues(Contact.TEL)][1]; for (int j = 0; j < c.countValues(Contact.TEL); j++) { strNos[j][0] = c.getString(Contact.TEL, j); /* switch(c.getAttributes(Contact.TEL, j)){ case Contact.ATTR_HOME: break; case Contact.attr }*/ } PhoneModel.setValues(strNos); PhoneModel.fireTableModelChanged(); //PhoneModel.setValues(values); break; case Contact.PHOTO_URL: case Contact.PHOTO: byte[] pic = c.getBinary(Contact.PHOTO, 0); ContactPic.setImage(Image.createImage(pic, 0, pic.length)); break; } } } catch (Exception ee) { ee.printStackTrace(); } }

Reply With Quote


