I am using Google Maps Android API v2 for my Android application. There I initialize the GoogleMap as follows: onCreate
SupportMapFragment fm = (SupportMapFragment)getSupportFragmentManager().findFragmentById(R.id.map); mGoogleMap = fm.getMap();
In my application, I need to perform some background tasks, and I use AsybcTask for this. Although progress is in the background, I want to update the map. Please refer to the following sample.
@Override protected Void doInBackground(Void...voids) { while(Condition) { mGoogleMap.clear(); mGoogleMap.addMarker(marker); Thread.sleep(5000); } }
I know that I cannot directly access user interface components inside the doInBackground method. Access to common user interface components, such as buttons, edittexts, textviews, can be obtained by analyzing the application context in the AsyncTask class. But I canβt find a way to access GoogleMap from the doInBackground method. Could you give me a solution.
source share