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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 2, 20262026-06-02T04:52:19+00:00 2026-06-02T04:52:19+00:00

I am working on ImageView in which I want to set an image into

  • 0

I am working on ImageView in which I want to set an image into Imageview but that Image(byte array) is coming directly from web server.. The concept is:

1) I am sending various parameteres to web server and in return the web server is sending me an image of that particular ID.(Just an Image, not the URL)

2) Now I want to show that Image directly into ImageView without saving into the SD card, so that whenever the user wants to see any other ID related Image, the Image should come directly from server and we are not saving it at our end.

[Editted]

Fetching value from server and return it in byte[]

     static BufferedReader in=null;

byte[] result_image;
          DefaultHttpClient httpClient = new DefaultHttpClient();

        HttpPost httpPost = new HttpPost(uri1);
        if(list!=null)
        {

        UrlEncodedFormEntity formEntity = new UrlEncodedFormEntity(list);
        httpPost.setEntity(formEntity);

        }
         //URI uri=httpPost.getURI();
        HttpResponse httpResponse = httpClient.execute(httpPost);
        in = new BufferedReader(new InputStreamReader(httpResponse.getEntity().getContent()));
        StringBuffer sb = new StringBuffer("");
        String line = "";
       // String NL = System.getProperty("line.separator");
        while ((line = in.readLine()) != null) {
              sb.append(line +" "); //sb.append(line +NL);
        }
        in.close();



       result_image = String.valueOf(sb).getBytes();

}
    catch(UnsupportedEncodingException e)
    {
        String err = (e.getMessage()==null)?"Cant connect to server":e.getMessage();
        Log.e("Network Error:",err); 
    }
    catch (MalformedURLException e) {
        String err = (e.getMessage()==null)?"Malformed Exception":e.getMessage();
        Log.e("Malformed Exception:",err); 

     } 
     catch(Exception ex)
     {
        // Log.i("Exception,ex", ex.getMessage());
         String err = (ex.getMessage()==null)?"NetworkConnectionException":ex.getMessage();
         Log.e("NetworkConnectionException:",err); 
     }
    finally {

        if (in != null) {
            try {
                    in.close();
             } catch (Exception ex) {
                 String err = (ex.getMessage()==null)?"Excepion":ex.getMessage();
                 Log.e("Exception:",err); 
            }
        }

Here the result_image is a byte [] and using this byte[] am decoding it and shwing it in Bitmap..Please help…
Any help into this is really appreciated..
Thanks..

  • 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-02T04:52:22+00:00Added an answer on June 2, 2026 at 4:52 am

    The decodeByteArray() method is the suggested way to do this.
    If its not working for you, You can decode it manually like the following code.

    URL yourl = new URL(src);
    HttpURLConnection connection = (HttpURLConnection) yourl.openConnection();
    connection.setDoInput(true);
    connection.connect();
    InputStream input = connection.getInputStream();                                
    bis = new BufferedInputStream(input,int);                   
    baf = new ByteArrayBuffer(int);
    
    int current = 0;                        
    while ((current = bis.read()) != -1) {                  
    baf.append((byte) current);
    }
    

    Hope the above code shows some alternate ideas to you. Happy coding.

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

Sidebar

Related Questions

I've created a custom listview which is working great apart from the fact that
I want to rotate imageview with continuously looping on android.my code rotate is working
Working with an undisclosed API, I found a function that can set the number
I got a 9 patch image which is the background of some imageview on
I'm working on an Android application that needs to download an image and display
Table view cell imageView is working on the simulator but not on the device..
I have an ImageView which I want to smoothly zoom on double tap. Currently
I am working on an app which I want to register in the Share
I'm dragging an imageView around the screen which is working great. At the moment,
I have a ViewFlipper which holds a single ImageView. i want to be able

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.