I am not able to explain the following issue.
I am working on an Android app. MainActivity has a method that calls a webservice to retrieve data.
I am checking the data and there is something very strange.
This is how am I getting the data:
private void getData() {
// SqLite database handler
db = new SQLiteHandler(this.getApplicationContext());
// session manager
session = new SessionManager(this.getApplicationContext());
if (!session.isLoggedIn()) {
logoutUser();
}
// Fetching user details from sqlite
HashMap<String, String> user = db.getUserDetails();
String name = user.get("name");
String email = user.get("email");
String imagen = user.get("imagen");
String user_id = user.get("uid");
String nivel_usuario = user.get("nivel_usuario");
Log.d("HOLA PERFIL", "UID LOGEADO en sqlite: " + nivel_usuario);
String id = user_id;
loading = ProgressDialog.show(this,"Please wait...","Loading data...",false,false);
String url = ConfigPerfil.DATA_URL+id;
StringRequest stringRequest = new StringRequest(url, new Response.Listener<String>() {
@Override
public void onResponse(String response) {
loading.dismiss();
showJSON(response);
}
},
new Response.ErrorListener() {
@Override
public void onErrorResponse(VolleyError error) {
// Toast.makeText(this,error.getMessage().toString(),Toast.LENGTH_LONG).show();
}
});
RequestQueue requestQueue = Volley.newRequestQueue(this);
requestQueue.add(stringRequest);
}
private void showJSON(String response){
Log.d("HOLA PERFIL", "RESPONSE: " + response);
String name="";
String email="";
String imagen = "";
String nivel_usuario = "";
String cel_verificado = "";
try {
JSONObject jsonObject = new JSONObject(response);
JSONArray result = jsonObject.getJSONArray(ConfigPerfil.JSON_ARRAY);
JSONObject collegeData = result.getJSONObject(0);
name = collegeData.getString(ConfigPerfil.KEY_NAME);
email = collegeData.getString(ConfigPerfil.KEY_EMAIL);
imagen = collegeData.getString(ConfigPerfil.KEY_IMAGEN);
nivel_usuario = collegeData.getString(ConfigPerfil.KEY_NIVEL_USUARIO );
cel_verificado = collegeData.getString(ConfigPerfil.KEY_CEL_VERIFICADO );
if (cel_verificado.equals("0")){
Toast.makeText(getApplicationContext(),
"CEL NUMBER NOT VERIFIED", Toast.LENGTH_LONG).show();
//Get_Cel();
Intent intent = new Intent(MainActivity.this,
VerificarCelActivity.class);
startActivity(intent);
}
else
{
Toast.makeText(getApplicationContext(),
"CEL NUMBER VERIFIED", Toast.LENGTH_LONG).show();
}
} catch (JSONException e) {
e.printStackTrace();
}
Log.d("HOLA PERFIL", "NIVEL USUARIO EN MAIN: " + nivel_usuario);
Log.d("HOLA PERFIL", "NIVEL USUARIO EN MAIN CEL VERIFICADO: " + cel_verificado);
txtNameU.setText(name);
txtWebsite.setText(email);
String cliente = "CLIENT";
String driver = "DRIVER";
if (nivel_usuario.equals("1")) {
txtTipo.setText(cliente);
}
if (nivel_usuario.equals("2")) {
txtTipo.setText(driver);
}
Glide.with(this).load(urlProfileImg+imagen)
.crossFade()
.thumbnail(0.5f)
.bitmapTransform(new CircleTransform(this))
.diskCacheStrategy(DiskCacheStrategy.ALL)
.into(imgProfile);
}
This log shows me following:
JSONObject jsonObject = new JSONObject(response);
10-25 23:29:43.639 7117-7117/com.juarezserver.sdocks D/HOLA PERFIL: RESPONSE: {"result":[{"name":"yo","id":"141","email":"modestovasco@gmail.com","imagen":"blue-user-icon.png","nombre":"FName","apellidos":"LName","nivel_usuario":"1","cel_verificado":"0","celular":"+526566742909"}]}
Please take a look at the value at cel_verificado = 0
If I execute the PHP directly from the browser, the echoed result is:
{"result":[{"name":"yo","id":"141","email":"modestovasco@gmail.com","imagen":"blue-user-icon.png","nombre":"FName","apellidos":"LName","nivel_usuario":"1","cel_verificado":"1","celular":"+526566742909"}]}
And the real value in the database is:
I am working to find the source for the issue for over 3 hours, and no success. Any clue to how to detect the problem is very welcome
EDITED
I guess it has to do with some kind of cache...