i am using AsyncTask for some part of my code but i have a jobSchedulerIntentService and i want to send data to server and receive some responses. i want to do same action without AsyncTask thread because my jobSchedulerIntentService have a thread. can i use AsyncTask without thread or i have to use another library ? witch library you can suppose me ? here is my code :
MyHttpClient.post("example.com/?", requestParams, new AsyncHttpResponseHandler() {
@Override
public void onSuccess(int statusCode, Header[] headers, byte[] responseBody) {
try {
JSONObject jsonObject = new JSONObject(new String(responseBody));
message = jsonObject.getString("user_id" );
} catch (JSONException e) {
Log.i(TAG, "error");
}
switch (message){
case "success_data":{
//do something
break;
}
case "failed_data":
case "failed_timer":
default:
Log.i(TAG, "error , try again");
}
}
@Override
public void onFailure(int statusCode, Header[] headers, byte[] responseBody, Throwable error) {
Log.i(TAG, "error"+statusCode);
}
@Override
public void onFinish() {
super.onFinish();
}
});