Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- private void checkLogin(final String email, final String password) {
- // Tag used to cancel the request
- String tag_string_req = "req_login";
- pDialog.setMessage("Logging in ...");
- showDialog();
- StringRequest strReq = new StringRequest(Method.POST,
- com.example.thomas.taken.app.AppConfig.URL_REGISTER, new Response.Listener<String>() {
- @Override
- public void onResponse(String response) {
- Log.d(TAG, "Login Response: " + response.toString());
- hideDialog();
- try {
- JSONObject jObj = new JSONObject(response);
- boolean error = jObj.getBoolean("error");
- // Check for error node in json
- if (!error) {
- // Launch main activity
- Intent intent = new Intent(LoginActivity.this,
- MainActivity.class);
- startActivity(intent);
- finish();
- } else {
- // Error in login. Get the error message
- String errorMsg = jObj.getString("error_msg");
- Toast.makeText(getApplicationContext(),
- errorMsg, Toast.LENGTH_LONG).show();
- }
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement