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

Android Discussion :

probléme de code pour mot de passe oublié


Sujet :

Android

Vue hybride

Message précédent Message précédent   Message suivant Message suivant
  1. #1
    Membre très actif
    Inscrit en
    Mars 2011
    Messages
    230
    Détails du profil
    Informations forums :
    Inscription : Mars 2011
    Messages : 230
    Par défaut probléme de code pour mot de passe oublié
    salut j'ai crée un bouton mots de oublié et une classe versification ,l’utilisateur doit taper son carte identité pour afficher son mot de passe mais le probléme quand je clique sur mot de passé oublié je tombe sur un message de exception
    voila ce que j'ai fait
    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
    public class Verification extends Activity {
     
     
    	EditText verifi;
    	Button verification2;
     
     
    	public String ReadSettings(Context context){ 
            FileInputStream fIn = null; 
            InputStreamReader isr = null; 
     
            char[] inputBuffer = new char[255]; 
            String data = null; 
     
            try{ 
             fIn = context.openFileInput("fichier.txt");       
                isr = new InputStreamReader(fIn); 
                isr.read(inputBuffer); 
                data = new String(inputBuffer); 
     
                Toast.makeText(context, " "+data,Toast.LENGTH_SHORT).show(); 
                } 
                catch (Exception e) {       
                          Toast.makeText(context, "Settings not read",Toast.LENGTH_SHORT).show(); 
                } 
     
                return data; 
           }
     
     
    	public void verification1 (View v)
    {String name=verifi.getText().toString();
     
    if(name.equals("0926882"))
    {	Toast.makeText(this,"mot CIN correct" ,Toast.LENGTH_SHORT);
    ReadSettings(getBaseContext());
    startActivity(new Intent(this,Principal.class));
    }
    else
    {
    	Toast.makeText(this,"mot CIN incorrect" ,Toast.LENGTH_SHORT);
    	}
    startActivity(new Intent(this,Principal.class));
     
    }
     
    	public void onCreate(Bundle savedInstanceState)
    	{
    	        super.onCreate(savedInstanceState);
    	        setContentView(R.layout.verification1);
     
     verifi=(EditText)findViewById(R.id.verifier);
     verification2=(Button)findViewById(R.id.verification);
     verification2.setOnClickListener(new OnClickListener() {
     
    	@Override
    	public void onClick(View v) {
    		// TODO Auto-generated method stub
    		verification1(verification2);	
    	}
    });
    	}}
    et j'ai l'appel de classe vérification dans la bouton mot de oublié
    Code : Sélectionner tout - Visualiser dans une fenêtre à part
    1
    2
    3
    	if(v==ok1) {
    			startActivity(new Intent(this, Verification.class));
    		}
    voila logcat
    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
    06-10 09:50:57.123: ERROR/AndroidRuntime(280): FATAL EXCEPTION: main
    06-10 09:50:57.123: ERROR/AndroidRuntime(280): java.lang.RuntimeException: Unable to start activity ComponentInfo{com.example.application/com.example.application.Verification}: java.lang.ClassCastException: android.widget.Button
    06-10 09:50:57.123: ERROR/AndroidRuntime(280):     at android.app.ActivityThread.performLaunchActivity(ActivityThread.java:2663)
    06-10 09:50:57.123: ERROR/AndroidRuntime(280):     at android.app.ActivityThread.handleLaunchActivity(ActivityThread.java:2679)
    06-10 09:50:57.123: ERROR/AndroidRuntime(280):     at android.app.ActivityThread.access$2300(ActivityThread.java:125)
    06-10 09:50:57.123: ERROR/AndroidRuntime(280):     at android.app.ActivityThread$H.handleMessage(ActivityThread.java:2033)
    06-10 09:50:57.123: ERROR/AndroidRuntime(280):     at android.os.Handler.dispatchMessage(Handler.java:99)
    06-10 09:50:57.123: ERROR/AndroidRuntime(280):     at android.os.Looper.loop(Looper.java:123)
    06-10 09:50:57.123: ERROR/AndroidRuntime(280):     at android.app.ActivityThread.main(ActivityThread.java:4627)
    06-10 09:50:57.123: ERROR/AndroidRuntime(280):     at java.lang.reflect.Method.invokeNative(Native Method)
    06-10 09:50:57.123: ERROR/AndroidRuntime(280):     at java.lang.reflect.Method.invoke(Method.java:521)
    06-10 09:50:57.123: ERROR/AndroidRuntime(280):     at com.android.internal.os.ZygoteInit$MethodAndArgsCaller.run(ZygoteInit.java:868)
    06-10 09:50:57.123: ERROR/AndroidRuntime(280):     at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:626)
    06-10 09:50:57.123: ERROR/AndroidRuntime(280):     at dalvik.system.NativeStart.main(Native Method)
    06-10 09:50:57.123: ERROR/AndroidRuntime(280): Caused by: java.lang.ClassCastException: android.widget.Button
    06-10 09:50:57.123: ERROR/AndroidRuntime(280):     at com.example.application.Verification.onCreate(Verification.java:70)
    06-10 09:50:57.123: ERROR/AndroidRuntime(280):     at android.app.Instrumentation.callActivityOnCreate(Instrumentation.java:1047)
    06-10 09:50:57.123: ERROR/AndroidRuntime(280):     at android.app.ActivityThread.performLaunchActivity(ActivityThread.java:2627)
    06-10 09:50:57.123: ERROR/AndroidRuntime(280):     ... 11 more

  2. #2
    Membre expérimenté
    Homme Profil pro
    Développeur Java
    Inscrit en
    Avril 2005
    Messages
    103
    Détails du profil
    Informations personnelles :
    Sexe : Homme
    Localisation : France, Puy de Dôme (Auvergne)

    Informations professionnelles :
    Activité : Développeur Java

    Informations forums :
    Inscription : Avril 2005
    Messages : 103
    Par défaut
    Le message d'erreur est clair, vous essayez de caster un élément en Button alors que visiblement ce n'est pas un button.

    Je pense que c'est à cette ligne :
    Code : Sélectionner tout - Visualiser dans une fenêtre à part
    verification2=(Button)findViewById(R.id.verification);
    Il faudrait vérifier dans le XML la classe du composant ayant pour id verification.

  3. #3
    Membre très actif
    Inscrit en
    Mars 2011
    Messages
    230
    Détails du profil
    Informations forums :
    Inscription : Mars 2011
    Messages : 230
    Par défaut
    Citation Envoyé par Aerinder Voir le message
    Le message d'erreur est clair, vous essayez de caster un élément en Button alors que visiblement ce n'est pas un button.

    Je pense que c'est à cette ligne :
    Code : Sélectionner tout - Visualiser dans une fenêtre à part
    verification2=(Button)findViewById(R.id.verification);
    Il faudrait vérifier dans le XML la classe du composant ayant pour id verification.
    Code : Sélectionner tout - Visualiser dans une fenêtre à part
    1
    2
    3
    4
    5
    6
    7
    8
    9
    <?xml version="1.0" encoding="utf-8"?>
    <LinearLayout
      xmlns:android="http://schemas.android.com/apk/res/android"
      android:layout_width="match_parent"
      android:layout_height="match_parent" android:orientation="vertical">
        <TextView android:text="Num Cin" android:id="@+id/textView1" android:layout_width="wrap_content" android:layout_height="wrap_content"></TextView>
        <EditText android:layout_height="wrap_content" android:text=" " android:id="@+id/verification" android:layout_width="match_parent"></EditText>
        <Button android:layout_height="wrap_content" android:id="@+id/verifier" android:text="verifier" android:layout_width="wrap_content"></Button>
    </LinearLayout>

  4. #4
    Membre expérimenté
    Homme Profil pro
    Développeur Java
    Inscrit en
    Avril 2005
    Messages
    103
    Détails du profil
    Informations personnelles :
    Sexe : Homme
    Localisation : France, Puy de Dôme (Auvergne)

    Informations professionnelles :
    Activité : Développeur Java

    Informations forums :
    Inscription : Avril 2005
    Messages : 103
    Par défaut
    Dans le XML le composant Button a pour id "verifier", le composant ayant pour id "verification" est un EditTextView.

  5. #5
    Membre très actif
    Inscrit en
    Mars 2011
    Messages
    230
    Détails du profil
    Informations forums :
    Inscription : Mars 2011
    Messages : 230
    Par défaut
    merciiiii j'ai trouvé le probléme

  6. #6
    Membre très actif
    Inscrit en
    Mars 2011
    Messages
    230
    Détails du profil
    Informations forums :
    Inscription : Mars 2011
    Messages : 230
    Par défaut
    pour la premiére fois quand j'ai tapé CIN il m'affiche le mot de passe mais quand j’essayai la 2 éme il me retourne a la interface principale

+ Répondre à la discussion
Cette discussion est résolue.

Discussions similaires

  1. mot de passe oublié pour accéder à l'éditeur VBA
    Par fctx2013 dans le forum Access
    Réponses: 1
    Dernier message: 14/08/2014, 10h19
  2. Mot de passe oublié pour compte administrateur
    Par Menhir dans le forum Windows 7
    Réponses: 11
    Dernier message: 15/01/2014, 21h47
  3. [MySQL] problème envoi mail pour mot de passe
    Par bonsam dans le forum PHP & Base de données
    Réponses: 1
    Dernier message: 17/11/2006, 20h57
  4. [authentification]mot de passe oublié
    Par dash dans le forum Access
    Réponses: 5
    Dernier message: 08/12/2005, 11h35
  5. mot de passe oublié
    Par sami1881 dans le forum Sécurité
    Réponses: 5
    Dernier message: 25/11/2005, 00h04

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