I simply have an asynctask that use a listener to communicate with the main activity. Where the response arrive arrive, and the first Toast will been showen wuth correct values. the problem is that in the try catch i can recover the values. so if or switch dont work anymore.
@Override
public void OnAsyncTaskComplete(String response) {
Toast.makeText(getContext(),((ActivityLogin) getActivity()).choiceButton+" result: "+response, Toast.LENGTH_LONG).show();
try {
JSONObject obj = new JSONObject(response);
String objservice = obj.getString("service");
String objstatuCode = obj.getString("status-code");
String objdescription = obj.getString("status-description");
JSONObject result = obj.getJSONObject("result");
if(!objstatuCode.equals("200") || objstatuCode.equals(null)){
Toast.makeText(getContext(), objstatuCode+"", Toast.LENGTH_SHORT).show();
return;
} else {
Toast.makeText(getContext(), objstatuCode+"", Toast.LENGTH_SHORT).show();
return;
}
} catch (JSONException e){
e.printStackTrace();
}
}
Aucun commentaire:
Enregistrer un commentaire