I am working on Login page and data receiving by server.Here IP, username and password is Entered by user. When IP is correct so he is checked the username and password.After that he is receiving the JSON
message.Here, result is saved the ""User exists"" and i am checking the "User exists".
When i am tried to convert in JSONObject
so he gives the error.....
here is the error description
JSON Response: "User Exists"
MainActivity.java
private class HttpAsyncTask extends AsyncTask<String, Void, String>{
@Override
protected String doInBackground(String... urls) {
return GET(urls[0]);
}
@Override
protected void onPostExecute(String result) {
try {
JSONObject jsonResponse = new JSONObject(result);
if(jsonResponse.equals("User exists")){
Toast.makeText(getBaseContext(),"Login Successfully",Toast.LENGTH_LONG).show();
Intent intent = new Intent(getApplicationContext(),Welcome.class);
startActivity(intent);
}
else{
Toast.makeText(getBaseContext(),"User does not exists",Toast.LENGTH_LONG).show();
}
} catch (JSONException e) {
e.printStackTrace();
}
}
}
LogCat
12-27 10:53:20.662 507-572/system_process E/WifiStateMachine: [1,482,836,000,662 ms] noteScanstart no scan source uid -1
12-27 10:53:21.375 6641-6662/com.example.anew.addbtnontitlebar D/result: "User exists"
12-27 10:53:21.376 6641-6641/com.example.anew.addbtnontitlebar D/error: Value User exists of type java.lang.String cannot be converted to JSONObject
12-27 10:53:23.168 507-572/system_process E/WifiStateMachine: [1,482,836,003,168 ms] noteScanEnd no scan source onTime=0