lundi 27 février 2017

Android JsonElement in if condition to check equalt to

I have a problrm with the JsonElement to chck one if condition in my project. How can i solve it ?

my string constants

public static final Integer RESULT_CODE_OK = 200;
public static final String RESULT_SUCCESS_OK = "true";
public static final String TAG_STATUS = "status";
public static final String TAG_SUCCESS = "success";

this is my constants file.

my json elements

JsonElement apiStatus=response.body().get(Constants.TAG_STATUS); 
JsonElement apiSuccess=response.body().get(Constants.TAG_SUCCESS);

I want to check below conditoin to do some task

 if ((apiStatus.equals(Constants.RESULT_CODE_OK)) &&
                        (apiSuccess.equals(Constants.RESULT_SUCCESS_OK)) ) { //data received successfully
    // some task 
}else{ //while retrieving data something went wrong.
// do some task for the else.
}

If done like this it is always goes else loop.

I have printed the above two variable on logcat. The value is absolutly fine for the if loop. Where i am doing wrong ?

Aucun commentaire:

Enregistrer un commentaire