When I pass arg this way everything works:
new MerrTeDhenatEDegeve().execute("https://navigator.bkt.com.al/bktnavigator/al/deget/al_ilamre_deget.php");
When I pass arg this way it crashes:
sh_d sh_d_instance = new sh_d();
new MerrTeDhenatEDegeve().execute(new String(sh_d_instance.deshifro(url_Deget)));
this is my async class:
class MerrTeDhenatEDegeve extends AsyncTask<String, String, String> {
// Marrja e te dhenave te degeve
protected String doInBackground(String... args) {
// Ketu po krijojme parametrat qe do te na duhet per te krijuar querin ne db
List<NameValuePair> params = new ArrayList<NameValuePair>();
// Ketu po bejme kerkesen per tek serveri dhe presim te marrim pergjigjen e json ne string
JSONObject jsonDega = jParserDega.makeHttpRequest(args[0], "GET", params);
try {
// Si fillim kontrollojme nqs kemi sukses ne marrjen e te dhenave apo jo
int sukses = jsonDega.getInt(TAG_SUKSES);
if (sukses == 1) {
// Ne rast suksesi atehere dmth qe kemi marre te dhenat e degeve dhe fillojme qe ti vendosim ato ne listat perkatese te tyre
Deget = jsonDega.getJSONArray(TAG_DEGET);
// Bredhim tek secili objekt me te dhenat e vektorit json dhe per secilin prej objekteve marrim vlerat qe na duhen
for (int i = 0; i < Deget.length(); i++) {
JSONObject VlObj = Deget.getJSONObject(i);
// Rruajme te dhenat ne listat perkatese ne menyre qe pastaj ti kapim globalisht
listaDegaID.add(VlObj.getString(TAG_DEGE_DID));
listaDegaEmrave.add(VlObj.getString(TAG_DEGE_EMRI));
listaDegaAdresave.add(VlObj.getString(TAG_DEGE_ADRESA));
listaDegaQyteteve.add(VlObj.getString(TAG_DEGE_QYTETI));
listaDegaLat.add(VlObj.getString(TAG_DEGE_LATITUDE));
listaDegaLng.add(VlObj.getString(TAG_DEGE_LONGITUDE));
listaDegaUrlFoto1.add(VlObj.getString(TAG_DEGE_URLFOTO_1));
}
}
} catch (JSONException e) {
e.printStackTrace();
}
return null;
}
}
So it crashes when it gets the data from another method which returns string.
Please I need help. Thank you
Which errors are you having? Can you please post the stacktrace? It is hard to say something wihtout looking at the stack, however, I would tell you to check the result of this
deshifro
method. If it is returning null it is likely that you get a nullPointerException here:JSONObject jsonDega = jParserDega.makeHttpRequest(args[0], "GET", params);