[Solved] How to get the JSON error response and toast it?
[ad_1] Just change this code: jObject = new JSONObject(result); if (jObject.has(“error”)) { String aJsonString = jObject.getString(“error”); Toast.makeText(getBaseContext(), aJsonString, Toast.LENGTH_SHORT).show(); } else { Toast.makeText(getBaseContext(), “Login Successful”, Toast.LENGTH_SHORT).show(); } } catch (JSONException e1) { // TODO Auto-generated catch block e1.printStackTrace(); Toast.makeText(getBaseContext(),result+”” , Toast.LENGTH_SHORT).show(); } So by this code, if your response is not JSON it will throw … Read more