Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • SEARCH
  • Home
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 9054841
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 16, 20262026-06-16T13:47:18+00:00 2026-06-16T13:47:18+00:00

In my app , i have an Arraylist of image urls and that has

  • 0

In my app , i have an Arraylist of image urls and that has to be downloaded as bitmap and save in another Arraylist , so that i could set them as the map-markers in the mapview . My code is

for( int i=0 ; i < Get_Feed_image.size() ; i++)
{
    Get_Feed_image_bitmap.add(DownloadImage(Get_Feed_image.get(i)));
}

And my DownloadImage method :

private Bitmap DownloadImage(String URL) 
    {
        Bitmap bitmap = null;
        InputStream in = null;
        try 
        {
            in = OpenHttpConnection(URL);
            bitmap = BitmapFactory.decodeStream(in);
            in.close();
        }
        catch (IOException e1) 
        {
            e1.printStackTrace();
        }
        return bitmap;
    }

    private InputStream OpenHttpConnection(String urlString) throws IOException 
    {
        InputStream in = null;
        int response = -1;

        URL url = new URL(urlString);
        URLConnection conn = url.openConnection();

        if (!(conn instanceof HttpURLConnection))
            throw new IOException("Not an HTTP connection");

        try 
        {
            HttpURLConnection httpConn = (HttpURLConnection) conn;
            httpConn.setAllowUserInteraction(false);
            httpConn.setInstanceFollowRedirects(true);
            httpConn.setRequestMethod("GET");
            httpConn.connect();

            response = httpConn.getResponseCode();
            if (response == HttpURLConnection.HTTP_OK) 
            {
                in = httpConn.getInputStream();
            }
        }
        catch (Exception ex) 
        {
            throw new IOException("Error connecting");
        }
        return in;
    }

And i get Logcat as ,

12-31 17:29:43.269: E/AndroidRuntime(14572): FATAL EXCEPTION: AsyncTask #5
12-31 17:29:43.269: E/AndroidRuntime(14572): java.lang.RuntimeException: An error occured while executing doInBackground()
12-31 17:29:43.269: E/AndroidRuntime(14572):    at android.os.AsyncTask$3.done(AsyncTask.java:200)
12-31 17:29:43.269: E/AndroidRuntime(14572):    at java.util.concurrent.FutureTask$Sync.innerSetException(FutureTask.java:274)
12-31 17:29:43.269: E/AndroidRuntime(14572):    at java.util.concurrent.FutureTask.setException(FutureTask.java:125)
12-31 17:29:43.269: E/AndroidRuntime(14572):    at java.util.concurrent.FutureTask$Sync.innerRun(FutureTask.java:308)
12-31 17:29:43.269: E/AndroidRuntime(14572):    at java.util.concurrent.FutureTask.run(FutureTask.java:138)
12-31 17:29:43.269: E/AndroidRuntime(14572):    at java.util.concurrent.ThreadPoolExecutor.runWorker(ThreadPoolExecutor.java:1088)
12-31 17:29:43.269: E/AndroidRuntime(14572):    at java.util.concurrent.ThreadPoolExecutor$Worker.run(ThreadPoolExecutor.java:581)
12-31 17:29:43.269: E/AndroidRuntime(14572):    at java.lang.Thread.run(Thread.java:1019)
12-31 17:29:43.269: E/AndroidRuntime(14572): Caused by: java.lang.NullPointerException
12-31 17:29:43.269: E/AndroidRuntime(14572):    at com.live.Feed.DownloadImage(Feed.java:279)
12-31 17:29:43.269: E/AndroidRuntime(14572):    at com.live.Feed.access$1(Feed.java:271)
12-31 17:29:43.269: E/AndroidRuntime(14572):    at com.live.Feed$Startsyntask.doInBackground(Feed.java:383)
12-31 17:29:43.269: E/AndroidRuntime(14572):    at com.live.Feed$Startsyntask.doInBackground(Feed.java:1)
12-31 17:29:43.269: E/AndroidRuntime(14572):    at android.os.AsyncTask$2.call(AsyncTask.java:185)
12-31 17:29:43.269: E/AndroidRuntime(14572):    at java.util.concurrent.FutureTask$Sync.innerRun(FutureTask.java:306)
12-31 17:29:43.269: E/AndroidRuntime(14572):    ... 4 more

i get my Force Close at in.close();

IF there are minimal Images , i mean minimal urls in the array , it works fine .
Or if my Network is Very fast , it works fine .Otherwise i get Force close .

Suggest me to fix this issue , Thanks in Advance . . . .

  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-06-16T13:47:19+00:00Added an answer on June 16, 2026 at 1:47 pm

    Instead of preparing ArrayList<Bitmap>, you should manage only ArrayList<String> i.e. Urls

    Why you should manage ArrayList? and How?

    You should use the image caching algorithm so that once image is downloaded it will get cached and load it from cache as and when required. It would be easy to manage actually.

    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

My app have a background image that fills the screen. I'd like to display
I have an app that is a little bit slow. I thoutght it could
I have a GWT/GAE project that has an arraylist of Strings on the server
I have a little app that have by default youtube as homepage. You can
I have app in which i have recorded sound files i want that i
I have an app that is available from the Android Market. Some users have
In a simple Spring 3 MVC app I have a few drop downs that
I have an ArrayCollection that shows up on the main screen of my app.
In my app I have an array List<Friends> friends =new ArrayList<Friends>(); where Friends is
I have an arraylist and I want to use arrays.sort to sort them alphabetically,

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.