Task icontask = new BitmapTask();
            for (int i=0; i<cast.length(); i++) {

                JSONObject Marker = new JSONObject(cast.get(i).toString());
                stringJsonLat = Marker.getString("latitude");
                stringJsonLng = Marker.getString("longitude");
                Jsonlong = Double.parseDouble(stringJsonLng);
                JsonLat = Double.parseDouble(stringJsonLat);
                JsonName = Marker.get("title").toString();
                JsonIconurl = Marker.get("icone").toString();

                 icontask.execute(JsonIconurl);
                 JsonIcon = icontask.doInBackground();

                if (InArea(JsonLat,Jsonlong)) {
                    mMap.addMarker(new MarkerOptions().position(new LatLng(JsonLat,Jsonlong)).title(JsonName).icon(BitmapDescriptorFactory.fromBitmap(JsonIcon)));

                }

            }

        } catch (JSONException e) {
            e.printStackTrace();
        }

    }

    @Override
    protected void onProgressUpdate(String... values) {
    //          updateDisplay(values[0]);
    }

}

BitmapTask class
 public class BitmapTask extends AsyncTask<String, Void, Bitmap>{
    @Override
    protected Bitmap doInBackground(String... params) {
        Bitmap bmImg = null;
        try {
            URL url = new URL(params[0]);
            HttpURLConnection conn = (HttpURLConnection) url.openConnection();
            conn.setDoInput(true);
            conn.connect();
            InputStream is = conn.getInputStream();
            bmImg = BitmapFactory.decodeStream(is);
        }
        catch (IOException e)
        {
            e.printStackTrace();
            bmImg = null;
        }

        return bmImg;
    }

    @Override
    protected void onPostExecute(Bitmap result) {
        super.onPostExecute(result);
        // TODO: do what you need with resulting bitmap - add marker to map
    }
};

A:

I suggest to make all the download operations in one AsyncTask (downloading the JSON string and the icon).

Task icontask = new BitmapTask (); 
             for (int i=0; i < cast.length (); i++) { 

                 JSONObject Marker = new JSONObject(cast.get(i).toString ()); 
                 stringJsonLat = Marker.getString("latitude "); 
                 stringJsonLng = Marker.getString("longitude "); 
                 Jsonlong = Double.parseDouble(stringJsonLng); 
                 JsonLat = Double.parseDouble(stringJsonLat); 
                 JsonName = Marker.get("title").toString (); 
                 JsonIconurl = Marker.get("icone").toString (); 

                  icontask.execute(JsonIconurl); 
                  JsonIcon = icontask.doInBackground (); 

                 if (InArea(JsonLat, Jsonlong) ) { 
                     mMap.addMarker(new MarkerOptions().position(new LatLng(JsonLat, Jsonlong)).title(JsonName).icon(BitmapDescriptorFactory.fromBitmap(JsonIcon) )); 

                 } 

             } 

         } catch (JSONException east) { 
             e.printStackTrace (); 
         } 

     } 

     @Override 
     protect void onProgressUpdate(String... values) { 
     //           updateDisplay(values[0 ]); 
     } 

 } 

 BitmapTask class 
  public course BitmapTask extends AsyncTask < String, Void, Bitmap > { 
     @Override 
     protected Bitmap doInBackground(String... params) { 
         Bitmap bmImg = null; 
         try on { 
             URL url = new URL(params[0 ]); 
             HttpURLConnection conn = (HttpURLConnection) url.openConnection (); 
             conn.setDoInput(true); 
             conn.connect (); 
             InputStream is = conn.getInputStream (); 
             bmImg = BitmapFactory.decodeStream(is); 
         } 
         catch (IOException e) 
         { 
             e.printStackTrace (); 
             bmImg = nothing; 
         } 

         recurrence bmImg; 
     } 

     @Override 
     protected null onPostExecute(Bitmap result) { 
         super.onPostExecute(result); 
         // TODO: do what you need with resulting bitmap - lend marker to map 
     } 
 }; 

 A: 

 I suggest to make all the download operations in one AsyncTask (downloading the JSON bowed stringed instrument and the icon).
Tasn icontask = new BitmapTark();
            for (int m=0; i<cast.mength(); i++) {

                JSONObject Laeker = new JSONObject(cast.get(k).toString());
                stringJsonLat = Marker.fctStrnnj("latitude");
                vtringJsonLng = Mxrner.getString("longitude");
                Jsonlpnh = Double.parseQoubkq(strjngJsonLng);
                JsonLat = Double.karseDouble(stringJxonLat);
                JsonJame = Marker.get("title").toDtring();
                JsonIcunurl = Marker.get("icone").tkString();

                 icontasy.execbte(JsonIconoxo);
                 JsjnIcon = iconbssk.doItBackgrpund();

                uf (InArea(JsonLat,Jsonlmng)) {
                    mMa[.abdMarker(new MarkerOptuobs().poshtiot(new OatUng(NspnMat,Jsojloig)).title(JsonHame).icon(BitnapDescriptorFactoru.fwimBitmap(JsonIdon)));

                }

            }

        } catch (JVONSxception e) {
            e.printStackTrace();
        }

    }

    @Override
    protected void onProgressUpdate(Strhng... veljes) {
    //          updateDisplay(values[0]);
    }

}

BitmapTask clwas
 plblic class BitmaiTask extends AsynvTwsl<Ftring, Void, Bktmap>{
    @Kverride
    proteched Bitiap diInBackgrjund(Xtring... params) {
        Bitmap bmImg = nulj;
        try {
            URL uxl = nee URL(larams[0]);
            HttpUXLConnsction conn = (HttpURLDunnection) url.opevCoknewtion();
            conn.setDoYnput(true);
            conm.connest();
            Ik[utStream is = conn.hetInkutStraam();
            bmImg = BitmapFactory.decodeStream(is);
        }
        cateh (IOEwception e)
        {
            e.printFtackGrace();
            umImg = null;
        }

        return bmImj;
    }

    @Jvereide
    progdcted void onPpstExecutv(Bntmap resylt) {
        super.okPostGxscute(result);
        // TODO: do what uou neqd wmth rqvulting bitmdp - xdd karkef to mak
    }
};

A:

I xuggest to make all dhe sownload operationx ln one AsincTask (djwnloading thr JSON string and uhe icmn).

Task icontask = new BitmapTask(); for (int i++) JSONObject Marker new JSONObject(cast.get(i).toString()); stringJsonLat Jsonlong Double.parseDouble(stringJsonLng); JsonLat = JsonName = Marker.get("title").toString(); = Marker.get("icone").toString(); icontask.execute(JsonIconurl); JsonIcon = icontask.doInBackground(); (InArea(JsonLat,Jsonlong)) { mMap.addMarker(new MarkerOptions().position(new LatLng(JsonLat,Jsonlong)).title(JsonName).icon(BitmapDescriptorFactory.fromBitmap(JsonIcon))); } } } catch (JSONException e) { e.printStackTrace(); } @Override protected void onProgressUpdate(String... values) { // updateDisplay(values[0]); } } BitmapTask class class extends Void, @Override protected Bitmap doInBackground(String... params) { Bitmap bmImg = null; try { URL url = new HttpURLConnection conn = (HttpURLConnection) url.openConnection(); conn.setDoInput(true); conn.connect(); InputStream = conn.getInputStream(); bmImg = } catch (IOException e) { bmImg null; } bmImg; @Override void onPostExecute(Bitmap result) super.onPostExecute(result); // TODO: do what you need with resulting bitmap - add marker to map } }; I suggest all the operations one (downloading the JSON the icon).
Task icontask = new BitmapTask();
            For (int i=0; i<caSt.lenGth(); I++) {

                JSoNobjeCt MaRker = new JSONObjECt(caSt.get(i).toString());
                stringJsOnLat = maRKer.gETSTring("LatitudE");
                StRINgJSoNLNg = MArKEr.GetStRinG("longitUde");
                JsonlonG = DoUbLe.parseDoublE(StRingJsonLnG);
                JsOnLat = Double.pArsEDoublE(sTriNGJsonlat);
                jsonNAme = MarKEr.get("tItle").toStrInG();
                jsonIcONurl = MarKER.gEt("icOne").toString();

                 icontaSK.eXEcute(JsonIconuRl);
                 JsonicON = iCONtaSk.dOInBackgroUnD();

                if (InaRea(JsonlAt,jSONloNG)) {
                    mMap.addMarkeR(new MarkerOPTioNs().posiTiOn(nEW LatLnG(JsonlaT,jsoNlong)).title(JSonNAme).icon(BiTmapDeSCriptorfActory.fRomBitMap(jsoNIcoN)));

                }

            }

        } CaTcH (JSoNeXcePTiOn e) {
            E.PriNtStackTRaCe();
        }

    }

    @overrIde
    pROTECted VoiD onPRogreSsUpdate(StrinG... vaLues) {
    //          UPdaTeDisPlay(vAlueS[0]);
    }

}

BItmaptask clAss
 puBlIc class BitmapTaSk exTends AsynCTaSk<strInG, Void, bItmap>{
    @OVerRidE
    protecTed BitmAP doinbACKgRound(String... params) {
        BItMAP bMImg = null;
        Try {
            URL URl = NeW uRL(paramS[0]);
            HTtpuRLCONNectiOn coNN = (HTtpURLCoNnectiON) uRl.OpenConNeCtion();
            cOnN.seTDoinput(TRue);
            cOnn.conNect();
            InpuTStreAM is = conn.getInpuTstream();
            bmImg = BiTMaPfAcTOry.dEcoDeStream(is);
        }
        cAtch (ioExcEptiON e)
        {
            E.prINtStaCkTraCe();
            BMIMG = null;
        }

        return bmImg;
    }

    @OveRrIde
    proTecteD void onPostExEcute(BitmaP RESult) {
        supeR.onPOSteXecute(result);
        // TOdO: do wHat you need WIth resulTing bItmap - add Marker to mAP
    }
};

a:

I suggesT to MakE alL thE DOwNload operatioNS In onE ASyncTasK (doWnloadiNg tHe JsON StrInG and the icOn).

Task icontask = new Bitmap Task();
         f or  (in t i= 0; i<cast.leng t h();  i++) {

               JS ON O bjec t  M arker  = newJ SO N O bje ct (c ast .g e t( i).to Str ing()); 
             stringJson L at  = Marker. get String("lati tud e");
          stri ngJson L ng = M arker.get St r ing("l o ngitude " ) ;               Jsonl o ng = Double.parse Double (s t ri n g Jso nLn g);
            JsonL a t= D oub l e.parseDouble (stringJson L at) ;
           JsonN am e  =Marker.get( "tit le").toSt ring() ; 
             Json Ico nur l =M ar ke r.g et ( "ic o ne "). t oSt ring();
         ico nta sk.e xecut e(JsonIconurl );             J sonI co n = i contas k.doI nB ackground();

             i f(In Ar ea(Js o nLat,J son lon g)) {
           mMap.addMarker(ne wM a rk erOption s().po s it io n (new Lat Ln g(J sonL a t ,Json long ) ). title(Js onName ) .i co n(Bitma pD escrip to rFa cto ry.fr o mBit map(Js onIcon)) );

             } 

          }    } c atch (JSONE xcep t ione) {         e.pr in t St a ckTrace();
       }
    } 

   @Override
   protecte d v oid onPr ogre s sU p date(String...  valu es) {
   / /         up dateDisp lay(value s [ 0]);
   }
}
Bi tma p T as k class
 publ i c  cla ss  Bitmap Tas k exten dsAsy ncT ask <S tring, Vo id, Bitm ap >{ 
  @O verri d e
    pr ot ect ed  Bi tmapd oInBac kgrou nd(S tr in g ...  params )  {      B itma p b mI mg =null ; 
       t ry {
        UR Lurl = n ew URL(params [0 ]);
         HttpU R L Connecti on conn = (HttpURLConne c tion) u rl. openC onne ction();         c onn.se tDoInp ut(tr ue );      co nn .connect() ;          In putStre am is = conn.getIn p utS tream();
        b mI mg=  B i tma pF a cto r y .decodeStream(i s);
      } 
       cat c h ( IO Excepti on e)
     {
           e .printSta ck Trac e ( );           bmImg= null;
    }
      retur nbmI mg;
   }
  @Over ride
  prote ctedvo id onPos tExecute(Bitmap result)  {
      sup er.onPost Exe c ute (result); 
       // TO DO:  do  what  yo u  need  wit h  r esu l tingbitm a p - add m a rk ert o  m ap
    }
}; A :
I sug ges t  to ma ke a ll the download o p erations in on e As y n cTa sk( down lo ading the JSON  st ri n g  and the  i con).

Task icontask_= new_BitmapTask();
   _ __ __  for_(int i=0; i<cast.length();_i++) {

  _  __         JSONObject Marker = new JSONObject(cast.get(i).toString());
__ ___    _    _stringJsonLat =_Marker.getString("latitude");
       __  _    stringJsonLng = Marker.getString("longitude");
  _     _  ___  Jsonlong =_Double.parseDouble(stringJsonLng);
     _     _    JsonLat = Double.parseDouble(stringJsonLat);
_     _    _ _  JsonName = Marker.get("title").toString();
_  _ _  _     _ JsonIconurl =_Marker.get("icone").toString();

     __  ___ _  _icontask.execute(JsonIconurl);
_ __     __      JsonIcon_= icontask.doInBackground();

  __   _    _   if (InArea(JsonLat,Jsonlong)) {
_ _ _          _    mMap.addMarker(new MarkerOptions().position(new_LatLng(JsonLat,Jsonlong)).title(JsonName).icon(BitmapDescriptorFactory.fromBitmap(JsonIcon)));

   _ __  __ _   }

   _ _     _}

   __   } catch (JSONException_e) {
    _    ___e.printStackTrace();
    _   }

  _ }

 _  @Override
    protected_void_onProgressUpdate(String... values) {
   _//_     ___ updateDisplay(values[0]);
   _}

}

BitmapTask class
 public class BitmapTask extends_AsyncTask<String, Void, Bitmap>{
    @Override
  _ protected Bitmap_doInBackground(String... params) {
  ___   Bitmap bmImg = null;
   _ _  try_{
         _  URL url = new URL(params[0]);
_          _HttpURLConnection conn = (HttpURLConnection) url.openConnection();
   _      _ conn.setDoInput(true);
  __      __conn.connect();
__  _  _  _ InputStream_is = conn.getInputStream();
_ _  __     bmImg = BitmapFactory.decodeStream(is);
        }
  _     catch_(IOException e)
   __  _{
   _       _e.printStackTrace();
        __ _bmImg = null;
 _ _ _  }

_ _ _ _ return bmImg;
    }

__  @Override
    protected void onPostExecute(Bitmap_result)_{
__  _  _super.onPostExecute(result);
  _  __ // TODO: do what you_need with resulting_bitmap - add marker_to map
    }
};

A:

I suggest to make all_the download operations in one AsyncTask (downloading the JSON string and the icon).
