IdentifiantMot de passe
Loading...
Mot de passe oublié ?Je m'inscris ! (gratuit)
Navigation

Inscrivez-vous gratuitement
pour pouvoir participer, suivre les réponses en temps réel, voter pour les messages, poser vos propres questions et recevoir la newsletter

Java ME Discussion :

PIM APIs Liste de contact - Plantage


Sujet :

Java ME

  1. #1
    Membre régulier
    Homme Profil pro
    Développeur informatique
    Inscrit en
    Mai 2005
    Messages
    119
    Détails du profil
    Informations personnelles :
    Sexe : Homme
    Âge : 38
    Localisation : Belgique

    Informations professionnelles :
    Activité : Développeur informatique

    Informations forums :
    Inscription : Mai 2005
    Messages : 119
    Points : 106
    Points
    106
    Par défaut PIM APIs Liste de contact - Plantage
    Yop à tous,

    Voila j'ai un souci, j'ai codé un application de test qui devrait en principe retrouvé un contact par sont nom.

    L'ennui c'est que le programme plante à cette ligne :

    if(cContact.getString(Contact.NAME,0).compareTo("Sandrine") == 0){

    Aucun message d'erreur , rien, l'application plante complètement. Comment dois-je récupérer le nom d'un contact ?

    J'ai esseye comme ceci aussi, mais même plantage :
    if(cContact.getString(Contact.NAME,Conctact.NAME).compareTo("Sandrine") == 0){

    Voici le code complèt de l'application, il est tout petit


    Code : Sélectionner tout - Visualiser dans une fenêtre à part
    1
    2
    3
    4
    5
    6
    7
    8
    9
    10
    11
    12
    13
    14
    15
    16
    17
    18
    19
    20
    21
    22
    23
    24
    25
    26
    27
    28
    29
    30
    31
    32
    33
    34
    35
    36
    37
    38
    39
    40
    41
    42
    43
    44
    45
    46
    47
    48
    49
    50
    51
    52
    53
    54
    55
    56
    57
    58
    59
    60
    61
    62
    63
    64
    65
    66
    67
    68
    69
    70
    71
    72
    73
    74
    75
    76
    77
    78
    79
    import javax.microedition.midlet.MIDlet;
    import javax.microedition.lcdui.Command;
    import javax.microedition.lcdui.CommandListener;
    import javax.microedition.lcdui.Form;
    import javax.microedition.lcdui.Display;
    import javax.microedition.lcdui.Displayable;
    import javax.microedition.lcdui.*;
    // PIM APIs
    import javax.microedition.pim.*;
     
    // Generated class. Modify.
    public final class MyCLdcl extends MIDlet implements CommandListener {
        private final Command exitCommand;
        private final Form mainForm;
        private PIM pimHinst;
        private ContactList clMyContact;
     
        public MyCLdcl() {
    	// Constructor. Place your code here.   
            mainForm = new Form("MyConctactListTest");
            exitCommand = new Command("Exit", Command.EXIT, 1);
            mainForm.addCommand(exitCommand);
            mainForm.setCommandListener(this);
            Display.getDisplay(this).setCurrent(mainForm);
        }
     
        protected void startApp() {
    	String szPimVersion;        
    	// Testing if the PIM APIs are supported.
    	if((szPimVersion = System.getProperty("microedition.pim.version")) == null){
    		mainForm.append("Your mobile do not support the PIM APIs");
    	}else{
    		pimHinst = PIM.getInstance();
     
    		try{
    			clMyContact = (ContactList) pimHinst.openPIMList(PIM.CONTACT_LIST,PIM.READ_ONLY);
     
    			java.util.Enumeration enumContacts = clMyContact.items();
    			Contact cContact;
    			boolean boFinded = false;
    			while(enumContacts.hasMoreElements()) {
    				cContact = (Contact) enumContacts.nextElement();
    				if(cContact.getString(Contact.NAME,0).compareTo("Sandrine") == 0){
    					boFinded = true;				
    				}
    			}
    			if(!boFinded){
    				mainForm.append("Not Finded");
    			}else{
    				mainForm.append("Finded");;
    			}
     
    		}catch (PIMException pe) {
    			mainForm.append("No such list");
    			for(int i=0;i<5000000;i++);
    		} catch (SecurityException se) {
    			mainForm.append("MIDlet is not allowed access to the specified list");
    			for(int i=0;i<5000000;i++);
    		}
     
    	}
        }
     
        protected void pauseApp() {
            // Place your code here.
        }
     
        protected void destroyApp(boolean unconditional) {
            // Place your code here.
        }
     
        public void commandAction(Command c, Displayable d) {
            // Place your code here.
            if (c == exitCommand) {
                destroyApp(false);
                notifyDestroyed();
            }
        }
    }
    Merci d'avance. cela me serait d'une très grande aide.
    ++

    deck_bsd

    /*************************************/
    [http://dckapps.azurewebsites.net/]

  2. #2
    Membre averti
    Inscrit en
    Juin 2003
    Messages
    292
    Détails du profil
    Informations forums :
    Inscription : Juin 2003
    Messages : 292
    Points : 317
    Points
    317
    Par défaut
    essaye ca plus tot:
    Code : Sélectionner tout - Visualiser dans une fenêtre à part
    1
    2
     
    if(cContact.getString(Contact.NAME,0).equals("Sandrine")){
    Cheers,

    H

  3. #3
    Membre du Club
    Profil pro
    Inscrit en
    Novembre 2004
    Messages
    61
    Détails du profil
    Informations personnelles :
    Localisation : Belgique

    Informations forums :
    Inscription : Novembre 2004
    Messages : 61
    Points : 62
    Points
    62
    Par défaut
    Vérifie aussi que ton mobile supporte bien la PIM API

Discussions similaires

  1. Réponses: 7
    Dernier message: 28/03/2007, 12h16
  2. [SOAP] Récupérer la liste des contacts
    Par amika dans le forum XML/XSL et SOAP
    Réponses: 1
    Dernier message: 16/01/2007, 00h23
  3. Comment accéder à la liste des contacts
    Par Akira dans le forum Java ME
    Réponses: 7
    Dernier message: 06/11/2006, 14h59
  4. [SHELL API] Liste des Icônes dans le casier (et position)..
    Par ARDILLER dans le forum API, COM et SDKs
    Réponses: 4
    Dernier message: 07/05/2005, 13h37
  5. Comment récupérer la liste des contacts de outlook express?
    Par arnaud_verlaine dans le forum Outlook Express / Windows Mail
    Réponses: 6
    Dernier message: 12/10/2004, 15h53

Partager

Partager
  • Envoyer la discussion sur Viadeo
  • Envoyer la discussion sur Twitter
  • Envoyer la discussion sur Google
  • Envoyer la discussion sur Facebook
  • Envoyer la discussion sur Digg
  • Envoyer la discussion sur Delicious
  • Envoyer la discussion sur MySpace
  • Envoyer la discussion sur Yahoo