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 8704445
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 13, 20262026-06-13T03:06:27+00:00 2026-06-13T03:06:27+00:00

I am trying to display my image but it doesn’t show: public Bitmap getUserPic(String

  • 0

I am trying to display my image but it doesn’t show:

public Bitmap getUserPic(String picID) {
    String imageURL;
    Bitmap bitmap = null;
    Log.d("BITMAP", "Loading Picture");
    imageURL = picID;
    Log.d("image url", picID);
    try {
        bitmap = BitmapFactory.decodeStream((InputStream)new URL(imageURL).getContent());
    } catch (Exception e) {
        Log.d("BITMAP", "Loading Picture FAILED");
        e.printStackTrace();
    }
    return bitmap;
}

Logcat output: (how do i display my logcat output neater?)

10-19 17:01:50.835: D/image url(8636): http://sphotos-c.ak.fbcdn.net/hphotos-ak-prn1/c0.0.403.403/p403x403/554229_4774210003216_2100715293_n.jpg
10-19 17:01:50.840: D/BITMAP(8636): Loading Picture FAILED 10-19
17:01:50.840: W/System.err(8636): android.os.NetworkOnMainThreadException 10-19 17:01:50.840: W/System.err(8636): at android.os.StrictMode$AndroidBlockGuardPolicy.onNetwork(StrictMode.java:1099)
10-19 17:01:50.840: W/System.err(8636): at java.net.InetAddress.lookupHostByName(InetAddress.java:391) 10-19
17:01:50.840: W/System.err(8636): at java.net.InetAddress.getAllByNameImpl(InetAddress.java:242) 10-19
17:01:50.840: W/System.err(8636): at java.net.InetAddress.getAllByName(InetAddress.java:220) 10-19
17:01:50.840: W/System.err(8636): at libcore.net.http.HttpConnection.<init>(HttpConnection.java:71) 10-19
17:01:50.840: W/System.err(8636): at libcore.net.http.HttpConnection.<init>(HttpConnection.java:50) 10-19
17:01:50.840: W/System.err(8636): at libcore.net.http.HttpConnection$Address.connect(HttpConnection.java:351)
10-19 17:01:50.840: W/System.err(8636):     at
libcore.net.http.HttpConnectionPool.get(HttpConnectionPool.java:86)
10-19 17:01:50.840: W/System.err(8636):     at
libcore.net.http.HttpConnection.connect(HttpConnection.java:128) 10-19
17:01:50.840: W/System.err(8636):   at
libcore.net.http.HttpEngine.openSocketConnection(HttpEngine.java:308)
10-19 17:01:50.840: W/System.err(8636):     at
libcore.net.http.HttpEngine.connect(HttpEngine.java:303) 10-19
17:01:50.840: W/System.err(8636):   at
libcore.net.http.HttpEngine.sendSocketRequest(HttpEngine.java:282)
10-19 17:01:50.840: W/System.err(8636):     at
libcore.net.http.HttpEngine.sendRequest(HttpEngine.java:232) 10-19
17:01:50.840: W/System.err(8636):   at
libcore.net.http.HttpURLConnectionImpl.connect(HttpURLConnectionImpl.java:80)
10-19 17:01:50.840: W/System.err(8636):     at
java.net.URLConnection.getContent(URLConnection.java:194) 10-19
17:01:50.840: W/System.err(8636):   at
java.net.URL.getContent(URL.java:447) 10-19 
17:01:50.840: W/System.err(8636): at jp.gr.java_conf.akabeko.testimagegallery.MainActivity.getUserPic(MainActivity.java:275)
10-19 17:01:50.845: W/System.err(8636): at jp.gr.java_conf.akabeko.testimagegallery.MainActivity$fetchArticles.onPostExecute(MainActivity.java:251)
10-19 17:01:50.845: W/System.err(8636): at jp.gr.java_conf.akabeko.testimagegallery.MainActivity$fetchArticles.onPostExecute(MainActivity.java:1)
10-19 17:01:50.845: W/System.err(8636): at android.os.AsyncTask.finish(AsyncTask.java:602) 10-19 17:01:50.845:
W/System.err(8636): at android.os.AsyncTask.access$600(AsyncTask.java:156) 10-19
17:01:50.845: W/System.err(8636): at android.os.AsyncTask$InternalHandler.handleMessage(AsyncTask.java:615)
10-19 17:01:50.845: W/System.err(8636): at android.os.Handler.dispatchMessage(Handler.java:99) 10-19
17:01:50.845: W/System.err(8636): at android.os.Looper.loop(Looper.java:137) 10-19 
17:01:50.845: W/System.err(8636): at android.app.ActivityThread.main(ActivityThread.java:4517) 10-19
17:01:50.845: W/System.err(8636): at java.lang.reflect.Method.invokeNative(Native Method) 10-19
17:01:50.845: W/System.err(8636): at java.lang.reflect.Method.invoke(Method.java:511) 10-19 
17:01:50.845: W/System.err(8636): at com.android.internal.os.ZygoteInit$MethodAndArgsCaller.run(ZygoteInit.java:995)
10-19 17:01:50.845: W/System.err(8636): at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:762) 10-19
17:01:50.845: W/System.err(8636): at dalvik.system.NativeStart.main(Native Method) 10-19 17:01:50.915: D/CLIPBOARD(8636): Hide Clipboard dialog at Starting input: finished by someone else... !
  • 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-13T03:06:28+00:00Added an answer on June 13, 2026 at 3:06 am

    The exception is thrown when an application attempts to perform a networking operation on its main thread.This is only thrown for applications targeting the Honeycomb SDK or higher. Applications targeting earlier SDK versions are allowed to do networking on their main event loop threads, but it’s heavily discouraged.

    Use an AsyncTask to get the image on a seperate thread and then assign
    it to display on onPostExecute and Voila! it should work.

    Refer this for Async task: http://android-developers.blogspot.in/2009/05/painless-threading.html

    There is a dirty fix but I would recommend never to use this

     StrictMode.ThreadPolicy policy = new StrictMode.ThreadPolicy.Builder().permitAll().build();
    
    StrictMode.setThreadPolicy(policy); 
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I am trying to display a GIF image in my GUI, and it doesn't
I'm trying to display the example of image_graphviz Here , but it doesn't display
I am trying to display an image on a Canvas , but when I
I'm trying to display image data read in from a binary file (I have
I am trying to display an image in a gridview, however, the columns that
I am trying to display an image in NSImageView. However when I place an
I'm trying to display an image in a WebView in an Android app. The
So I'm trying to display an image that is ouside the path of my
I'm a beginner to the iOS development, and I'm trying to display an image
I am trying to display a Loading Image in a new JFrame when the

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.