In my android project I use many AsynTask in on activity. I need the code that stop AsynTask when I start other AsynTask.
I'm using myAsynTask.cancel(true); in my android project. But it does stop the AsynTask. I tried many time but sill don't work.
protected String doInBackground(String... args) {
HashMap<String, String> params = new HashMap<>();
params.put("id", args[0]);
Log.d("get value: ", params.toString());
JSONObject json = jParser.makeHttpRequest(url_comment, "GET", params);
Log.d("All matches: ", json.toString());
if(isCancelled()) {
finish();
}
else {
try {
int success = json.getInt(TAG_SUCCESS);
if (success == 1) {
JSONmatches = json.getJSONArray(TAG_vedio);
for (int i = 0; i < JSONmatches.length(); i++) {
JSONObject c = JSONmatches.getJSONObject(i);
String title = c.getString(TAG_title);
String url = c.getString(TAG_url);
HashMap<String, String> map = new HashMap<String, String>();
map.put(TAG_title, title);
map.put(TAG_url, url);
arrayList22.add(map);
}
}
} catch (JSONException e) {
e.printStackTrace();
}
}
return null;
}
Please help me.