I have an object Car
that has this constructor:
public Car(int idCar, String name)
{
this.idCar = idCar;
this.name = name;
}
Here I don't have any problem so I created one object Car
named newCar
, like this:
Car newCar = new Car(1,"StrongCar");
The problem that I have it's that I want to pass this newCar
to my AsyncTask
, named modifyCar
as a parameter, but I don't know how to do this.
I have searched in SO and I found this question: AsyncTask passing custom objects
but it doesn't solved my problem because in the solution that it is given they only pass an String
to the AsyncTask
and not the entirely object.
What I want it's to pass the entirely object as a parameter to the AsyncTask.
According to the solution that it is given in the question that I put above, I tried to do this to pass the object to the AsyncTask
.
new modifyCar(newCar).execute();
So I declared the AsyncTask like this:
class modifyCar extends AsyncTask<Car, Integer, ArrayList<Evento>> {
protected void onPreExecute()
{
}
protected ArrayList<Evento> doInBackground(Car... newCarAsync)
{
//The rest of the code using newCarAsync
}
protected void onProgressUpdate()
{
}
protected void onPostExecute()
{
}
}
But I don't know if it is correct or not. If not, what I should do for that purpose?
Thanks in advance!