You Are Here:

Community: Developer Discussion Boards

#1 Old Adding picture to the contact using jsr75 (NOKIA 6630,6680) - 2005-08-30, 11:51

Join Date: May 2003
Posts: 35
manik_jandial
Offline
Registered User
//i have tested this code on NOKIA 6630 and NOKIA 6680.....

These are the variables used:

private ContactList phoneList ;
private String conListName[]; //0 - phone, 1 sim
private PIM pimObject ;
Contact contact ;




/////the contents of the function goes like this



pimObject = PIM.getInstance();
conListName = pimObject.listPIMLists(PIM.CONTACT_LIST);



try {
phoneList = (ContactList) (pimObject.openPIMList(PIM.CONTACT_LIST,
PIM.READ_WRITE, conListName[0]));///for phone address book
}
catch (PIMException e) {
return;
}

contact = phoneList.createContact();


///adding name to the phonebook//it is done successfully
String[] name1 = new String[phoneList.stringArraySize(Contact.NAME)];
if (phoneList.isSupportedArrayElement(Contact.NAME, Contact.NAME_GIVEN))
name1[Contact.NAME_GIVEN] = name;
contact.addStringArray(Contact.NAME, PIMItem.ATTR_NONE, name1);


//adding telephone //this too is successful

try {
contact.addString(Contact.TEL, Contact.ATTR_HOME, number);
}
catch (Exception e) {}
//commiting these to the phonebook
try {
contact.commit();
}

catch (PIMException e) {
}




//here i make a image
//this image 1900 bytes
InputStream is = getClass().getResourceAsStream("/c.jpg");



try {
int length = is.available();
b = new byte[length];
while (is.read() != -1) {
is.read(b);
}
}
catch (Exception e) {
e.printStackTrace();
}

///i check here if this field(PHOTO) is supported

if (phoneList.isSupportedField(Contact.PHOTO)) {
try {
contact.addBinary(110, Contact.ATTR_NONE, b, 0, b.length);
}
catch (Exception e) {

}
}


try {
contact.commit();
}
catch (PIMException e) {
//now error occurs here it say insufficient data content.Its actually
//PIMException type 1(general error)
showAlert = true;
ee = Integer.toString(e.getReason());

}






//any comments would be appreciated.
//is there implementation problem in these phones
Reply With Quote

#2 Old Re: Adding picture to the contact using jsr75 (NOKIA 6630,6680) - 2005-08-30, 14:50

Join Date: Mar 2003
Posts: 6,209
petrib
Offline
Forum Nokia Champion
I don't know JSR-75 very well, but in the 6630 and 6680 Contacts database there's no longer (at least not based on the Contacts app user interface) any way to add a full-size photo; just a small thumbnail image.

Now the question is what this field is called/named & if it has any size and format restrictions (you seem to be trying to simply add a JPEG file byte by byte, which might not be OK).

What if you use the Contacts app and add a thumbnail image and then attempt to read and export the thumbnail to a file & then try to see what format/size/resolution it is in (JPEG, BMP, MBM, PNG, whatever)?
Reply With Quote

#3 Old Re: Adding picture to the contact using jsr75 (NOKIA 6630,6680) - 2005-08-30, 15:02

Join Date: May 2003
Posts: 35
manik_jandial
Offline
Registered User
Yes i have tried that also.i mean i transferred the jpeg image to the phone memory and than added it (add thumbnail option) .

also i used(getBinary(int field,int index)), this function returns the thumbnail (bytes )..... retrieved the byte data (image) that i have uploaded manually....it returns me proper data.


so that means it supports jpeg.


I tried with different sizes like 8x8, 16x16,24x24,32x32,64x64,128x128,256x256 but of no use ......
Reply With Quote

#4 Old Re: Adding picture to the contact using jsr75 (NOKIA 6630,6680) - 2005-12-13, 18:07

Join Date: Dec 2005
Posts: 2
dhalle
Offline
Registered User
Is there any Nokia guys out there that could answer to this question. I've got the same problem on my Nokia 6680. If adding a photo to a contact is not implemented, then ok, but just tell it!!!

Thanx,
David.
Reply With Quote

#5 Old Re: Adding picture to the contact using jsr75 (NOKIA 6630,6680) - 2006-07-06, 11:05

Join Date: Jul 2005
Posts: 64
pankaj_hotwani
Offline
Regular Contributor
Hi Manik and Dhalle,

I am getting the same error ("insufficient data content") while associating photo with a particular contact throug PIM api in nokia 6630. Please let me know if you people got any solution of this. I will be very thankfull to you guys..

Regards,
Pankaj.


Regards,
Pankaj Hotwani.
Reply With Quote

#6 Old Re: Adding picture to the contact using jsr75 (NOKIA 6630,6680) - 2007-01-06, 08:34

Join Date: Sep 2006
Posts: 77
Location: Delhi
Send a message via Yahoo to sunil_talent Send a message via Skype™ to sunil_talent
sunil_talent's Avatar
sunil_talent
Offline
Regular Contributor
Quote:
Originally Posted by manik_jandial
Yes i have tried that also.i mean i transferred the jpeg image to the phone memory and than added it (add thumbnail option) .

also i used(getBinary(int field,int index)), this function returns the thumbnail (bytes )..... retrieved the byte data (image) that i have uploaded manually....it returns me proper data.


so that means it supports jpeg.


I tried with different sizes like 8x8, 16x16,24x24,32x32,64x64,128x128,256x256 but of no use ......
Hi
I am also trying to access photo of Contact.
My code works well in emulator(WTK 2.5).. i.e. I am able create image using the byte[] returned by the metod getBinary(int field,int index).
But in Nokia 6630 its not working.
The byte[] returned by the method getBinary(int field,int index) in Nokia 6630 can't create image.
I noticed that, the values of byte[] returned by the method getBinary(int field,int index) in emulator are varies from -127 to +127 but in nokia 6630 its varies from 0 to +127. And for the same photo of same Contact (I transfered the vCard from handset to emulator) the length of byte[] returned by the method getBinary(int field,int index) in handset is more than that of emulator.
So i am unable to create the image.. Can anybody help me?
Reply With Quote

#7 Old Re: Adding picture to the contact using jsr75 (NOKIA 6630,6680) - 2007-01-16, 08:01

Join Date: Sep 2006
Posts: 77
Location: Delhi
Send a message via Yahoo to sunil_talent Send a message via Skype™ to sunil_talent
sunil_talent's Avatar
sunil_talent
Offline
Regular Contributor
Hi All
I got the solution to my problem.

In Nokia 6630, the byte array returned by the getBinary(field,index) method is the encrypted one. (BASE64).

I decrypted this byte array, and using the resulted decrypted array , i craeted the image.

Now Its working fine on nokia 6630. i.e. Now i am able to display the photo of a Contact.
Reply With Quote

#8 Old Question Re: Adding picture to the contact using jsr75 (NOKIA 6630,6680) - 2007-03-30, 18:12

Join Date: Sep 2006
Posts: 22
ismalg
Offline
Registered User
Hi all,

I am trying to add a picture as you are saiding, sunil_talent. But always I am receiving "The item has insufficient data content". This is my function:


public void createContact ()
{
ContactList phoneList ;
String conListName[]; //0 - phone, 1 sim
PIM pimObject ;
Contact contact;
String name = "is";
String number = "123";
byte b[] = null;;

pimObject = PIM.getInstance();
conListName = pimObject.listPIMLists(PIM.CONTACT_LIST);

try
{
phoneList = (ContactList) (pimObject.openPIMList(PIM.CONTACT_LIST,
PIM.READ_WRITE, conListName[0]));///for phone address book
}
catch (PIMException e)
{
return;
}

//PIMItem contact = (PIMItem) phoneList .createContact ();
contact = phoneList.createContact();

///adding name to the phonebook//it is done successfully
String[] name1 = new String[phoneList.stringArraySize(Contact.NAME)];
if (phoneList.isSupportedArrayElement(Contact.NAME, Contact.NAME_GIVEN))
name1[Contact.NAME_GIVEN] = name;
contact.addStringArray(Contact.NAME, PIMItem.ATTR_NONE, name1);

//adding telephone //this too is successful
try
{
contact.addString(Contact.TEL, Contact.ATTR_HOME, number);
}
catch (Exception e)
{
}

try
{
contact.commit();
}
catch (PIMException e)
{
}

byte raw[] = null;

try
{
Image newImage = Image .createImage ("/image.png");
raw = getByteArray(newImage);
}
catch (Exception e)
{
e.printStackTrace();
}

///i check here if this field(PHOTO) is supported
if (phoneList.isSupportedField(Contact.PHOTO))
{
try
{
byte encoded[] = Base64.encode(raw);
System.out.println ("encoded length = " + encoded.length);
contact .addBinary (Contact.PHOTO, Contact.ATTR_NONE, encoded, 0, encoded.length);
contact .commit();
}
catch (Exception e)
{
e.printStackTrace();
}
}
}



Please help me!!

Thanks manik_jandial for your help too.

Regards.

ismalg
Reply With Quote

#9 Old Question Re: Adding picture to the contact using jsr75 (NOKIA 6630,6680) - 2007-04-02, 10:05

Join Date: Sep 2006
Posts: 22
ismalg
Offline
Registered User
Any idea, please?

ismalg.
Reply With Quote
Reply « Previous Thread | Next Thread »
Display Modes
Thread Tools Search this Thread
Search this Thread:

Advanced Search

Posting Rules

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

vB code is On
Smilies are Off
[IMG] code is Off
HTML code is Off
Forum Jump
Similar Threads
Thread Thread Starter Forum Replies Last Post
Contact List Picture Size Tall-Guy Mobile Java Media (Graphics & Sounds) 0 2004-04-10 16:52
Nokia Comunicator 9500 alvisone General Discussion 2 2004-03-01 08:01
Create Contact Item with Ringtone and Picture y10913 General Symbian C++ 0 2004-02-27 19:01
Nokia Mobile VPN Client marcyl Symbian Networking & Messaging 1 2003-12-01 15:47
Nokia 3310 - Smart Messaging compatibility Nokia_Archive Smart Messaging 2 2002-05-22 14:22

Rate This

 
Bookmark this page: DeliciousDiggFacebookGoogleYahooStumbleUponRedditDiigoTechnocratiTwitter  Share this page Share this page Print this Page Print this page Invite a friend Invite a friend
京ICP备05048969号    Email Newsletters Press Terms & Conditions Privacy Policy Sitemap Contact Us © 2009 Nokia