title: Adding marker to google map from AsyncTask
body: <p>I am having a very strange problem which it is making me crazy. I add marker to my map from AsyncTask to avoid blocking the main thread. In Nexus 4 with 4.2.2 it is working fine but in tablet galaxy with 3.2 or galaxy ace with 2.3.7 it is giving me a null pointer exception when do map.addMarker(). The error is for the MarkerOption becuause if I create a MarkerOption in the OnProgrssUpdate is not having the error. I check that the object is not null and it is not. Even I put a log.d before the addMarker and the object is correct however I got the error. Here you have the code:</p>
  
  <pre><code>    private class MapItems extends AsyncTask&lt;Void, Item, Void&gt; {
          @Override
          protected Void doInBackground(Void... values) {
              int density = getResources().getDisplayMetrics().densityDpi;
              for (int companyId : companies) {
                  try {
                      Company company = DBCompanies.getCompany(db_path,
                              GSSettings.DBCODE, companyId);
                      LatLng pos = new LatLng(company.getLatitude(),
                              company.getLongitude());
                      if (pos.latitude == 0 &amp;&amp; pos.longitude == 0)
                          continue;
  
                      Subcategory subcategory = DBParameters.getSubcategory(
                              db_path, GSSettings.DBCODE, company
                                      .getSubcategoriesId()[0], Locale
                                      .getDefault().getLanguage());
  
  
      Bitmap bitmap;
                      if (subcategory.getMarker() != null
                              &amp;&amp; subcategory.getMarker().length &gt; 1)
                          bitmap = GSTools.getBitmapFromMDPI(
                                  subcategory.getMarker(), density);
                      else
                          bitmap = GSTools.getBitmapFromMDPI(
                                  subcategory0.getMarker(), density);
  
                      MarkerOptions markerOptions = new MarkerOptions()
                              .position(pos).anchor(0, 1)
                              .title(company.getName())
                              .snippet(subcategory.getName())
                      .icon(BitmapDescriptorFactory.fromBitmap(bitmap));
              Item item = new Item(markerOptions, company.getId());
  
              publishProgress(item);
          } catch (Exception e) {
          }
      }
      return null;
  }
      @Override
      protected void onProgressUpdate(Item... values) {
          try {
              MarkerOptions markerOptions = values[0].markerOptions;
              Log.d("marker", markerOptions.getTitle());
  
  
      //              markerOptions = new MarkerOptions()
      //                      .position(new LatLng(37.750087, -0.848522))
      //                      .anchor(0, 1)
      //                      .title("TT")
      //                      .icon(BitmapDescriptorFactory
      //                              .fromResource(R.drawable.ic_button_map));
              Marker m = map.addMarker(markerOptions);
              haspMap.put(m, values[0].comapnyId);
              Log.d("marker", markerOptions.getTitle());
  
          } catch (Exception e) {
              Log.d("marker", e.toString());
          }
  
          super.onProgressUpdate(values);
      }
      }
  </code></pre>
  
  <p>If I use the MarkerOption commented works. Any idea????</p>
  
  <p>Thanks.</p>