private void doInscri( String firstNameValue, String lastNameValue, String emailValue, String passwordValue) { hideButton(); progressBar.setVisibility(View.VISIBLE); // github sign in Call<ResponseBody> call = gitHubService.storeUser(firstNameValue, lastNameValue, emailValue, passwordValue); Log.d("user", firstNameValue + " " + lastNameValue + " " + emailValue + " " + passwordValue); call.enqueue( new Callback<ResponseBody>() { @Override public void onResponse(Call<ResponseBody> call, Response<ResponseBody> response) { progressBar.setVisibility(View.GONE); JSONObject jsonObject = null; User user = null; try { jsonObject = new JSONObject(response.body().string()); String result = jsonObject.getString("success"); if (result.equals("User exist")) { email.setError("User email exist !"); emailConfirmed.getEditText().setText(""); email.requestFocus(); mdperreur(); } else { JSONObject userJson = jsonObject.getJSONObject("user"); user = new User( userJson.getString("id_User"), userJson.getString("login"), userJson.getString("nom") + " " + userJson.getString("prenom")); AuthUtils.saveUser(InscriptionActivity.this, user); succ(); } } catch (JSONException | IOException | NullPointerException e) { e.printStackTrace(); mdperreur(); } // AuthUtils.saveToken(InscriptionActivity.this, token); AuthUtils.saveUser(InscriptionActivity.this, user); Log.d("success", "last one"); } @Override public void onFailure(Call<ResponseBody> call, Throwable t) { progressBar.setVisibility(View.GONE); Toast.makeText(InscriptionActivity.this, "Unable to conenect", Toast.LENGTH_SHORT) .show(); mdperreur(); } }); }