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 :

Android Develppement Login erreur


Sujet :

Android

Vue hybride

Message précédent Message précédent   Message suivant Message suivant
  1. #1
    Membre confirmé
    Homme Profil pro
    Développeur android & Java Web application
    Inscrit en
    Avril 2016
    Messages
    105
    Détails du profil
    Informations personnelles :
    Sexe : Homme
    Localisation : Côte d'Ivoire

    Informations professionnelles :
    Activité : Développeur android & Java Web application
    Secteur : High Tech - Éditeur de logiciels

    Informations forums :
    Inscription : Avril 2016
    Messages : 105
    Par défaut Android Develppement Login erreur
    Salut la famille,

    je realise une application Android, a la connexion ou on se logue (Authentification) : j'ai cette erreur ::

    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
     
    D/request!: starting
     
    W/dalvikvm: threadid=12: thread exiting with uncaught exception (group=0xacd23b20)
    E/AndroidRuntime: FATAL EXCEPTION: AsyncTask #1
                      Process: com.ngser.opa.qrcode, PID: 10170
                      java.lang.RuntimeException: An error occured while executing doInBackground()
                          at android.os.AsyncTask$3.done(AsyncTask.java:300)
                          at java.util.concurrent.FutureTask.finishCompletion(FutureTask.java:355)
                          at java.util.concurrent.FutureTask.setException(FutureTask.java:222)
                          at java.util.concurrent.FutureTask.run(FutureTask.java:242)
                          at android.os.AsyncTask$SerialExecutor$1.run(AsyncTask.java:231)
                          at java.util.concurrent.ThreadPoolExecutor.runWorker(ThreadPoolExecutor.java:1112)
                          at java.util.concurrent.ThreadPoolExecutor$Worker.run(ThreadPoolExecutor.java:587)
                          at java.lang.Thread.run(Thread.java:841)
                       Caused by: android.view.ViewRootImpl$CalledFromWrongThreadException: Only the original thread that created a view hierarchy can touch its views.
                          at android.view.ViewRootImpl.checkThread(ViewRootImpl.java:6094)
                          at android.view.ViewRootImpl.requestLayout(ViewRootImpl.java:824)
                          at android.view.View.requestLayout(View.java:16431)
                          at android.view.View.requestLayout(View.java:16431)
                          at android.view.View.requestLayout(View.java:16431)
                          at android.view.View.requestLayout(View.java:16431)
                          at android.view.View.requestLayout(View.java:16431)
                          at android.view.View.requestLayout(View.java:16431)
                          at android.widget.RelativeLayout.requestLayout(RelativeLayout.java:352)
                          at android.view.View.requestLayout(View.java:16431)
                          at android.widget.RelativeLayout.requestLayout(RelativeLayout.java:352)
                          at android.view.View.requestLayout(View.java:16431)
                          at android.view.View.requestLayout(View.java:16431)
                          at android.widget.TextView.checkForRelayout(TextView.java:6600)
                          at android.widget.TextView.setText(TextView.java:3813)
                          at android.widget.TextView.setText(TextView.java:3671)
                          at android.widget.TextView.setText(TextView.java:3646)
                          at com.ngser.opa.qrcode.LoginActivity$AttemptLogin.doInBackground(LoginActivity.java:141)
                          at com.ngser.opa.qrcode.LoginActivity$AttemptLogin.doInBackground(LoginActivity.java:79)
                          at android.os.AsyncTask$2.call(AsyncTask.java:288)
                          at java.util.concurrent.FutureTask.run(FutureTask.java:237)
                          at android.os.AsyncTask$SerialExecutor$1.run(AsyncTask.java:231)*
                          at java.util.concurrent.ThreadPoolExecutor.runWorker(ThreadPoolExecutor.java:1112)*
                          at java.util.concurrent.ThreadPoolExecutor$Worker.run(ThreadPoolExecutor.java:587)*
                          at java.lang.Thread.run(Thread.java:841)*
    Voici mon code ::

    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
    80
    81
    82
    83
    84
    85
    86
    87
    88
    89
    90
    91
    92
    93
    94
    95
    96
    97
    98
    99
    100
    101
    102
    103
    104
    105
    106
    107
    108
    109
    110
    111
    112
    113
    114
    115
    116
    117
    118
    119
    120
    121
    122
    123
    124
    125
    126
    127
    128
    129
    130
    131
    132
    133
    134
    135
    136
    137
    138
    139
    140
    141
    142
    143
    144
    145
    146
    147
    148
    149
    150
    151
    152
    153
    154
    155
    156
     
    package com.ngser.opa.qrcode;
     
    import android.app.ProgressDialog;
    import android.content.Intent;
    import android.os.AsyncTask;
    import android.support.v7.app.AppCompatActivity;
    import android.os.Bundle;
    import android.util.Log;
    import android.view.View;
    import android.widget.Button;
    import android.widget.EditText;
    import android.widget.TextView;
    import android.widget.Toast;
     
    import org.apache.http.NameValuePair;
    import org.apache.http.message.BasicNameValuePair;
    import org.json.JSONException;
    import org.json.JSONObject;
     
    import java.math.BigInteger;
    import java.security.MessageDigest;
    import java.security.NoSuchAlgorithmException;
    import java.util.ArrayList;
    import java.util.List;
    import java.util.logging.Level;
    import java.util.logging.Logger;
     
    /**
     * Created by Opa on 30/09/2016.
     */
     
    public class LoginActivity extends AppCompatActivity implements View.OnClickListener {
     
        private EditText user, pass;
        private TextView loginErrorMsg;
        private Button bLogin;
     
        // Progress Dialog
     
        private ProgressDialog pDialog;
     
        // JSON parser class
        JSONParser jsonParser = new JSONParser();
     
     
     
        @Override
        protected void onCreate(Bundle savedInstanceState) {
     
            super.onCreate(savedInstanceState);
            setContentView(R.layout.activity_login);
     
            user = (EditText)findViewById(R.id.edi_numero);
            pass = (EditText)findViewById(R.id.edit_code);
     
            loginErrorMsg = (TextView) findViewById(R.id.ErrorMsg);
     
            bLogin = (Button)findViewById(R.id.buton_login);
            bLogin.setOnClickListener(this);
     
        }
     
     
        @Override
        public void onClick(View v) {
            // TODO Auto-generated method stub
            switch (v.getId()) {
                case R.id.buton_login:
                    new AttemptLogin().execute();
                    // here we have used, switch case, because on login activity you may
                    // also want to show registration button, so if the user is new ! we can go the
                    // registration activity , other than this we could also do this without switch
                    // case.
                    default: break;
            }
     
        }
     
           public class AttemptLogin extends AsyncTask<String, String, String> {
     
                @Override
                protected void onPreExecute() {
                    super.onPreExecute();
                    pDialog = new ProgressDialog(LoginActivity.this);
                    pDialog.setTitle("PayMoney Connexion");
                    pDialog.setMessage("Authentification...");
                    pDialog.setIndeterminate(false);
                    pDialog.setCancelable(true);
                    pDialog.show();
                }
     
                @Override
                protected String doInBackground(String... args) {
                    // TODO Auto-generated method stub
                    // here Check for success tag
                    int success;
     
                    String username = user.getText().toString();
                    String password = pass.getText().toString();
     
                    String convertMd5 = "";
     
                    try {
                        MessageDigest md = MessageDigest.getInstance("MD5");
     
                        md.update(password.getBytes(), 0, pass.length());
     
                        convertMd5 = new BigInteger(1, md.digest()).toString(16);
                    } catch (NoSuchAlgorithmException ex) {
                        Logger.getLogger(LoginActivity.class.getName()).log(Level.SEVERE, null, ex);
                    }
     
                    String lien = "http://localhost:8585/Json/webresources/compte/numero/"+username+"/"+convertMd5;
     
                    List<NameValuePair> params = new ArrayList <NameValuePair>();
                    params.add(new BasicNameValuePair("lien", lien));
     
                    Log.d("request!", "starting");
     
                    JSONObject json = jsonParser.makeHttpRequest(lien, "GET", params);
     
                    // checking  log for json response
                    Log.d("Login attempt", json.toString());
     
                    // success tag for json
                    //success = json.getInt(TAG_SUCCESS);
     
                    if (json.toString().isEmpty()) {
                        Log.d("Successfully Login!", json.toString());
     
                        Intent ii = new Intent(LoginActivity.this, MainActivity.class);
                        finish();
                        // this finish() method is used to tell android os that we are done with current
                        // activity now! Moving to other activity
                        startActivity(ii);
     
                        Toast.makeText(LoginActivity.this, "Vous etes connecté", Toast.LENGTH_SHORT).show();
                    }else{
     
                        pDialog.dismiss();
                        loginErrorMsg.setText("Incorrect username/password");
     
                    }
     
                    return null;
                }
                /**
                 * Once the background process is done we need to  Dismiss the progress dialog asap
                 * **/
            protected void onPostExecute(String message) {
     
                pDialog.dismiss();
            }
            }
    }

  2. #2
    Modérateur
    Avatar de grunk
    Homme Profil pro
    Lead dév - Architecte
    Inscrit en
    Août 2003
    Messages
    6 693
    Détails du profil
    Informations personnelles :
    Sexe : Homme
    Âge : 41
    Localisation : France, Côte d'Or (Bourgogne)

    Informations professionnelles :
    Activité : Lead dév - Architecte
    Secteur : Industrie

    Informations forums :
    Inscription : Août 2003
    Messages : 6 693
    Par défaut
    Tu ne peux pas depuis le doInBackground() d'une asynctask accéder à la vue de ton activité.
    Tu dois impérativement le faire ailleurs (onPreExecute, onPostExecute ...)
    Pry Framework php5 | N'oubliez pas de consulter les FAQ Java et les cours et tutoriels Java

  3. #3
    Membre confirmé
    Homme Profil pro
    Développeur android & Java Web application
    Inscrit en
    Avril 2016
    Messages
    105
    Détails du profil
    Informations personnelles :
    Sexe : Homme
    Localisation : Côte d'Ivoire

    Informations professionnelles :
    Activité : Développeur android & Java Web application
    Secteur : High Tech - Éditeur de logiciels

    Informations forums :
    Inscription : Avril 2016
    Messages : 105
    Par défaut
    Je comprends pas tu peux faire un exemple pour me montrer pour voir

Discussions similaires

  1. [Android 2.2] Erreur "Uncaught handler"
    Par toma_50 dans le forum Android
    Réponses: 12
    Dernier message: 27/02/2013, 23h10
  2. [Security] Probléme de redirection apres login erreur 404
    Par amadoulamine1 dans le forum Spring
    Réponses: 0
    Dernier message: 24/03/2011, 18h02
  3. [MySQL] login/mdp donnant une erreur 1 coup sur 2
    Par vincedjs dans le forum PHP & Base de données
    Réponses: 15
    Dernier message: 16/03/2006, 14h20
  4. [Sécurité] gestion erreur login mdp
    Par oceane751 dans le forum Langage
    Réponses: 19
    Dernier message: 03/11/2005, 11h58

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