11-03-2009 10:31 PM
Hi all
I am the beginner so please can any one help to retrive the contact in blackberry .
i know there is a api net.rim.blackberry.api.pdap but i dnt know how to use it . it have worked on retriving contact in j2me using PIM .
please if u have any sample code to retrive the contact please share it
Regards
Divya
11-03-2009 11:30 PM
Hope this will work.... Here I m invoking Contact List and on click on any Contact I m getting its MOBILE number..
**********************************************
final PIM pim = PIM.getInstance();
BlackBerryContactList contactList = null;
String number = "";
//*
try{
contactList = (BlackBerryContactList) pim.openPIMList(PIM.CONTACT_LIST, PIM.READ_WRITE); //// This will ///invoke ur contact list
}catch(Exception e)
{System.out.println("Error : : "+e);}
final PIMItem selectedItem = contactList.choose();
try{
int[] fieldIds = selectedItem.getFields();
int id;
for (int atrCount = 0;atrCount < selectedItem.countValues(Contact.TEL); ++atrCount)
{
switch(selectedItem.getAttributes(Contact.TEL, atrCount))
{
case Contact.ATTR_MOBILE:
String value = selectedItem.getString(Contact.TEL, atrCount);
System.out.println("GGGGGGGGGGGggg ot it :: "+value);
number = value;
break;
}
}
if(number != "")
{System.out.println("Innnnn");}
else
{
System.out.println("Outttttt");
Dialog.alert("OOPS not a mobile number!!");
System.out.println("Outttttt 1231231212122");
}
} catch(Exception e)
{System.out.println("EEEEEEEEEEEEEEEEEEEEEEEEEEEEE
if (selectedItem instanceof Contact)
{ System.out.println("User selected a Contact: " +selectedItem );
}
else if (selectedItem instanceof BlackBerryContactGroup)
{ System.out.println("User selected a BlackBerryContactGroup: " + selectedItem); }
else
{ // at this point we can assume that selectedItem==null, indicating user cancelled
System.out.println("User cancelled the selection"); }
**************************************************
Thnx....
11-03-2009 11:48 PM
I want to display the retrieved contact on List Field is it possible ?
How can i do it ??
11-03-2009 11:54 PM
Is it possible to retrieve the contacts without signing the certificate just for testing purpose
11-04-2009 12:06 AM
No, its not possible.You can test on the Simulator only without signing.
11-04-2009 12:12 AM
ok thanks, but i want to display the retrieved contacts along with contact name and contact number on the listfield how it is possible???
and i have tried the above code but i am getting exception "Push modal screen called by non -event thread"
please help me
11-04-2009 12:24 AM - last edited on 11-04-2009 12:34 AM
and i have tried the above code but i am getting exception "Push modal screen called by non -event thread" ,
but no errors but its not retrieving the contacts i am writing the above code in the constructor of my class (displaycontacts this extends MainScreen --this class displaycontatcs is called by main thread )
class pimaccess extends UiApplication {
pimaccess() {
displaycontacts homeScreen = new displaycontacts ();
pushScreen(displaycontacts );
}
public static void main(String[] args){
pimaccess myApp = new pimaccess();
myApp.enterEventDispatcher();
}
}
class displaycontacts extends MainScreen {
private MyObjectListField list;
private String[] phnum;
displaycontacts ()
{
//here i am writing the above code (retrives the contact)
//inside the for loop is am storing the telephonenumber in string array phnum[ ]
//list.set(phnum);
//this.add(list);
private class MyObjectListField extends ObjectListField {
public void drawListRow(ListField listField, Graphics graphics,
int index, int y, int width) {
graphics.drawText("- " + phnum[index], 0,
y, DrawStyle.ELLIPSIS, width);
}
};
}
Is it correct please help me??