How can I get mutiple url bitmap with asynctask

Well I want to download many of bitmap files with Asynctask. (This bitmap is located on the network)

If then what should do I do for this job?

private ArrayList<String> bitmapUrls; private ArrayList<Bitmap> bitarray;

.. bitmapUrls.add("Here's my bitmap url"); x 10 ..

public class DownloadImages extends AsyncTask<Void, Void, Bitmap> { @Override protected Bitmap doInBackground(Void... params) { Bitmap bitmap = null; for(String biturl:bitmapUrls){ bitmap = downloadBitmap(biturl); return bitmap; } } @Override protected void onPostExecute(Bitmap result) { bitarray.add(result); } public Bitmap downloadBitmap(String url) { final AndroidHttpClient client = AndroidHttpClient .newInstance("Android"); final HttpGet getRequest = new HttpGet(url); try { HttpResponse response = client.execute(getRequest); final int statusCode = response.getStatusLine().getStatusCode(); if (statusCode != HttpStatus.SC_OK) { Log.w("ImageDownloader", "Error " + statusCode + " while retrieving bitmap from " + url); return null; } final HttpEntity entity = response.getEntity(); if (entity != null) { InputStream inputStream = null; try { inputStream = entity.getContent(); final Bitmap bitmap = BitmapFactory .decodeStream(inputStream); return bitmap; } finally { if (inputStream != null) { inputStream.close(); } entity.consumeContent(); } } } catch (Exception e) { getRequest.abort(); } finally { if (client != null) { client.close(); } } return null; } }

As you see I really want to get bitarray result array in my code. Please give me an advice for improving this stuff code.

Category:android Views:2 Time:2018-02-12

Related post

  • How Can I get the URL parameter & Value in Coldfusion? 2009-12-14

    How Can I get the URL parameter & Value in Coldfusion? for Ex:- my URL is test.cfm?par1=val1&par2=val2&par3=val3 Is it possible to get the second parameter and its value directly? with <cfset param='#url.par2#'> I can get value of p

  • How can I get the correct currency with 2 decimal places in c#? 2011-11-07

    public PriceTable ConvertToUSDollar(decimal Amount,string Currency) { try { var toCurrency = "USD"; var fromCurrency = "AUD"; string url = string.Format(" {2}{0}%3D%3F{1}", fromCurrency .ToUpper(), toCu

  • How can I get an URL from a cursor object 2009-06-16

    I have a Cursor points to a Contact. How can I get an url built from that Cursor? I need to know that because from here I need to have an url so that I can build a phone uri,

  • How can I get the URL of an HTTPResponse 2010-11-15

    how can I get the URL of an HTTPResponse? I tried: response.getHeaders("Locations") But I obtained: 11-15 21:14:03.355: INFO/System.out(880): [Lorg.apache.http.Header;@43ea9568 --------------Solutions------------- You maybe be thinking of redirecting

  • How can I get the class name with contain 'map' in jquery? 2011-04-28

    Does anyone how can I get the class name with contain word 'map' with jquery? I'm using the following code to get the class name with map (eg. class="mapTest"), but it not work if the class contain 2 name (e.g class="abctest map test"). Does anyone k

  • How can I get GWT RequestFactory to with in a Gadget? 2011-06-20

    How can I get GWT RequestFactory to with in a Gadget? Getting GWT-RPC to work with Gadgets is explained here. I'm looking for a analogous solution for RequestFactory. I tried using the GadgetsRequestBuilder, so far I've managed to get the request to

  • How can I get CodeBlocks to compile with -std=c++0x with gcc? 2011-06-29

    How can I get CodeBlocks to compile with -std=c++0x with gcc? I would like to see if they treat new features with useful syntax highlighting. Also, I have a lot of stuff n C++-0x now. --------------Solutions------------- Easy: Put -std=c++0x -U__STRI

  • How can I get the URL of an in JavaScript? 2011-11-22

    I'm processing some text in JavaScript (using Node, so please no jQuery). I want to extract all URL's that are in <a> tags on the page. How can I do this in JavaScript? --------------Solutions------------- var myArray = preg_match_all("<a.*?

  • How can I get windows to talk with the Samsung phone again? 2012-12-12

    Original title: I have a samsung phone. when I was setting up the software to sync its files I some how told windows to ignore the phone. It does that very well. how can I get windows to talk with the phone again when I was setting up the software to

  • Have minolta magicolor 2300w laser and a vista 64 bit os, how can i get them to operate with each other? 2013-09-30


  • how can i get the orignal games with windows7? 2014-04-20

    How can i get the orignal games with windows7? --------------Solutions------------- If with "original games" you mean those included in Windows 7 (Chess Titans, Freecell and others), you probably have Windows 7 Professional where you must enable them

  • PHP: How can I get the URL that has been rewritten with mod_rewrite? 2011-07-05

    For example, if I rewrite /category/topic/post/ to /index.php?cat=1&topic=2&post=3, how can I get /index.php?cat=1&topic=2&post=3 using PHP? --------------Solutions------------- You can recreate it pretty easily. $_SERVER['PHP_SELF']

  • How can I get better response times with soundManager2? 2011-03-03

    Using soundManager2, I made a simple anchor with onclick="", but there is a big gap (almost half a second) before the sound is actually heard! This is, even though I pre-loaded the sound. How can I get a better response-time? Here is th

  • How can I get the Url of the web site which is using my web service? 2009-04-14

    I have developed a web service and host it on my server and I would like to know who is using this web service (site Url). I tryed to use "Request.UrlReferrer" but it is not returning any thing! any suggestions/Advices? --------------Solutions-------

  • How can i get the DomainName\AccountName with the .NET Framework? 2010-04-27

    How can i get the DomainName\AccountName as string with the .NET Framework? --------------Solutions------------- System.Security.Principal.WindowsIdentity.GetCurrent().Name.ToString() You can use the Environment.UserDomainName property to retrieve th

  • How can I get the URL from the default browser to use in my custom browser? 2010-11-02

    I am developing an Android app in which a type of browser will be included. As the user tries to open a URL, an intent resolver asks the user whether they want to complete the action using the default browser or a custom browser. This part of my app

  • How can I get system display name with Inno Setup? 2010-11-25

    How can I get system display name of a file, directory, or folder as it would be displayed in a system file browser? For example original CD is named somehow and I want to do little copy protection --------------Solutions------------- Inno Setup prov

  • How can I get all details objects with specified condition? 2011-05-16

    I have class A { String title static hasMany = [details: Detail] } class Detail { enum Type { ONE, TWO } String name Type type static belongsTo = [a: A] } How can I get list of all Details type ONE for specified object a? I tried def all_one = A.get(

  • How can I get the reflect constructor with Generics in Java? 2011-06-03

    now exists a class below: class A{ private A(HashMap map){ } } how can I get the constructor that the parameters are generics with reflection? EDIT : Question edited. --------------Solutions------------- You can't have templates in Java. You can have

  • How can I get the rows along with row count in SQL? 2011-06-23

    I have written the following query: select *, count(pk_id) as row_count from employee group by pk_id But I am not getting 1 as the row_count value for every column. How can I get the total number of rows returned as the result of the query? Can someo

  • How can I get maximum user referral with MySQL query? 2011-08-07

    I have created a new system that there can used with referral system, but how can I get the information about the user who has the largest number of referrals? I imagine the SQL command is like this: select * from user where refered_user=max(count(us

  • How can I get the span text with incremental id using jQuery? 2011-10-01

    I'm sorry guys I've changed my code to this: <table border="1"> <?php $a = array('apple','banana','grapes','pineapple'); for ($x=0;$x<=3;$x++) { ?> <tr> <td><div class='fruit' ><?php echo $a[$x]; ?></div>

  • How can I get send() to block with UDP? 2011-11-21

    I am writing a simple UDP-based client/server app and testing with both the client/server on localhost, and I would like for the sender to know when send() would have blocked. I am using Python, so I think I can do: s = socket.socket(socket.AF_INET,

  • How can I get name of element with jQuery? 2012-01-13

    How can I get name property of HTML element with jQuery? --------------Solutions------------- You should use attr('name') like this $('#yourid').attr('name') you should use an id selector, if you use a class selector you encounter problems because a

Copyright (C), All Rights Reserved.

processed in 0.174 (s). 11 q(s)