
Pasar variable ArrayList<String> a doInBackground
Publicado por Joaquín (24 intervenciones) el 28/01/2017 19:07:22
Quiero pasar la variable pidList del tipo ArrayList<String> a doInBackground de una clase que extiende de AsyncTask llamada ActualizarFavoritos. Para ello hago lo siguiente:
Y me da error al ejecutar la aplicación. En el log pone:
Caused by: java.lang.NullPointerException
En la línea que corresponde a: int success = json.getInt(TAG_SUCCESS);
Llevo dándole vueltas un tiempo y no encuentro donde me equivoco. Agradecería a quién me pudiera orientar.
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
…
if (pidList!=null){
new ActualizarFavoritos().execute(pidList);
}
…
Y en la clase ActualizarFavoritos:
class ActualizarFavoritos extends AsyncTask<ArrayList<String>, String, String> {
@Override
protected void onPreExecute() {
…
}
protected String doInBackground(ArrayList<String>... args) {
ArrayList<String> pidListpassed = args[0];
HashMap<String, ArrayList<String>> params = new HashMap<String, ArrayList<String>>();
params.put("pidList", pidListpassed);
JSONObject json = jParser.makeHttpRequest(url_favoritos, "POST", params);
try {
//SUCCESS TAG
int success = json.getInt(TAG_SUCCESS);
if (success == 1) {
…
}
} catch (JSONException e) {
e.printStackTrace();
}
return null;
}
protected void onPostExecute(String result) {
pDialog.dismiss();
}
Caused by: java.lang.NullPointerException
En la línea que corresponde a: int success = json.getInt(TAG_SUCCESS);
Llevo dándole vueltas un tiempo y no encuentro donde me equivoco. Agradecería a quién me pudiera orientar.
Valora esta pregunta


0