[I have a custom parcelable object Vehicle]
I have looked at AsyncTask but it wasn't too clear on this topic:
I would like to pass a String(which is the Vehicle ID of the Vehicle) into an AsyncTask, then in doInBackground() I have a method
mRemoteInterface.getTrackHistory();
which gives me an ArrayList. I would like to then, in onPostExecute() start an activity where both the Vehicle ID and ArrayList are extras.
This is an outline of what I wan't to be able to do. The issue is that I don't understand passing objects INTO the asynctask, and then from doInBackground() to onPostExecute() and from onPostExecute() back to the original execute call.
getTrackHistory.execute(WHAT SHOULD GO HERE?);
private class getTrackHistory extends
AsyncTask<String, Integer, Boolean **WHAT SHOULD GO HERE?**> {
@Override
protected Boolean doInBackground(
String... params) {
try {
String vehicleID = params[0];
listVehicleHistory = (ArrayList<Vehicle>) mRemoteInterface.getVehicleHistory(vehicleID);
} catch (Exception e) {
e.printStackTrace();
}
}
@Override
protected void onProgressUpdate(Integer... progress) {
}
@Override
protected void onPostExecute(Boolean worked) {
super.onPostExecute(worked);
Intent intent = new Intent(MainActivity.this,VehicleInfo.class);
intent.putExtra("Vehicle ID", toReturn);
intent.putParcelableArrayListExtra("VehicleHistory", listVehicleHistory);
startActivity(intent);
}
}