title: Accessing GoogleMap from outside the UI thread in Android
body: <p>I'm using Google Map Android API v2 for my android application. There I have initialize GoogleMap as follows inside onCreate</p>
  
  <pre><code>SupportMapFragment fm = (SupportMapFragment)getSupportFragmentManager().findFragmentById(R.id.map);
  mGoogleMap = fm.getMap();
  </code></pre>
  
  <p>In my application, I need to do some background tasks and I'm using AsybcTask for that. While progress through the background tasks I want to update the map. Please refer the following sample.</p>
  
  <pre><code>@Override
      protected Void doInBackground(Void...voids) {
          while(Condition)
          {
              mGoogleMap.clear();
              mGoogleMap.addMarker(marker);
              Thread.sleep(5000);
          }
       }
  </code></pre>
  
  <p>I know that I can't directly access UI components inside the doInBackground method. Common UI components like buttons, edittexts, textviews can be accessed by parsing the context of the application to the AsyncTask class. But I can't figure out a way to access GoogleMap from the doInBackground method. Could you please give me a solution.</p>