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
| public void onClick(View view) {
String email = inputEmail.getText().toString();
String password = inputPassword.getText().toString();
UserFunctions userFunction = new UserFunctions();
Log.d("Button", "Login");
JSONObject json = userFunction.loginUser(email,password);
try {
if (json.getString(KEY_SUCCESS) != null) {
loginErrorMsg.setText("");
String res = json.getString(KEY_SUCCESS);
if(Integer.parseInt(res) == 1){
DatabaseHandler db = new DatabaseHandler(getApplicationContext());
JSONObject json_user = json.getJSONObject("user");
//recuperation des données
String nom=json_user.optString("nom");
String prenom=json_user.optString("prenom");
Double lat;
lat=json_user.optDouble("lat");
String latStr = lat.toString();
Double lng =null;
lng=json_user.optDouble("lng");
String lngStr = lng.toString();
//Launch Dashboard Screen
Intent intent = new Intent(getApplicationContext(), LocalisationMobileActivity.class);
intent.putExtra("nom", nom);
intent.putExtra("prenom", prenom);
startActivity(intent);
}else{
// Error in login
loginErrorMsg.setText("Incorrect email ou mot de passe");
}
}
} catch (JSONException e1) {
e1.printStackTrace();
}
} |
Partager