I am sending JSONString
from MainActivity
to the GetLLRD
class which is being sent to the server from MyAsyntask
inner class in the GetLLRD
class then I am getting ArrayList<ItemDTO> data
object from the server which I want to pass to the map Activity
.
How can I start the map Activity
from the onPostExecute()
method and pass the ArrayList<ItemDTO> data
to it?
I appreciate any help.
GetRRLD class
public class GetLLRD {
public void post_selected(String json) {
new MyAsyncTask().execute(json);
}
class MyAsyncTask extends AsyncTask<String, Integer, List<ItemDTO>> {
@Override
protected List<ItemDTO> doInBackground(String... params) {
.
.
.
.
Gson gson = new Gson();
Type listType = new TypeToken<List<ItemDTO>>() {
}.getType();
ArrayList<ItemDTO> data = gson.fromJson(sb.toString(), listType);
.
.
.
.
return null;
}
protected void onPostExecute(ArrayList<ItemDTO> result) {
new Handler().postDelayed(new Runnable() {
@Override
public void run() {
new MyAsyncTask().execute();
System.out.println("The method onPostExcute() in GETLLRD class was invoked again");
}
}, 1*30 * 1000);
if (result != null) {
Intent intent = new Intent(GetLLRD.this, Map.class);
intent.putStringArrayListExtra("selected_route", result);
startActivity(intent);
startActivity(new Intent(getApplicationContext(), Map.class));
}
}
}
}
MapDataJSON class: import java.util.ArrayList;
public class MapDataJSON { ArrayList items;
public MapDataJSON(ArrayList<ItemDTO> items) {
super();
this.items = items;
}
public ArrayList<ItemDTO> getItems() {
return items;
}
public void setItems(ArrayList<ItemDTO> items) {
this.items = items;
}
public static class ItemDTO {
double latitude;
double longitude;
int route;
String direction;
public ItemDTO(double latitude, double longitude, int route,
String direction) {
super();
this.latitude = latitude;
this.longitude = longitude;
this.route = route;
this.direction = direction;
}
public double getLatitude() {
return latitude;
}
public double getLongitude() {
return longitude;
}
public int getRoute() {
return route;
}
public String getDirection() {
return direction;
}
public void setLatitude(double latitude) {
this.latitude = latitude;
}
public void setLongitude(double longitude) {
this.longitude = longitude;
}
public void setRoute(int route) {
this.route = route;
}
public void setDirection(String direction) {
this.direction = direction;
}
}
}