Reputation: 971
I implement a map on my activity but latitude and longitude are coming from a server. AsyncTask is requesting for those values but I don't know how I can wait for data to be received before launching the OnMapReadyCallback callback...
here's my code:
@Override
public void onCreate(Bundle savedInstanceState) {
....
//retrieve the latitude and longitude
new ProgressTask().execute();
m = ((SupportMapFragment) this.getSupportFragmentManager()
.findFragmentById(R.id.map));
//need to wait for AsyncTask...
m.getMapAsync(this);
I expected to launch the command
m.getMapAsync(this);
in the onPostExecute of my AsyncTask:
@Override
protected void onPostExecute(OnMapReadyCallback result) {
....
....
but I don't know how to pass in params the OnMapReadyCallback to the AsyncTask ?
Upvotes: 0
Views: 787
Reputation: 971
I finally found a solution (not sure this is the best one...) to retrieve the context of My Activity (which implements OnMapReadyCallback) I'm just calling the
m.getMapAsync(this);
from a method out of onPOstExecute:
@Override
protected void onPostExecute(Fragment result) {
....
loadMap();
}
public void loadMap(){
m.getMapAsync(this);
}
Upvotes: 1