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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 23, 20262026-05-23T13:05:00+00:00 2026-05-23T13:05:00+00:00

Hello i have this Json output and i am calling in my android app.

  • 0

Hello i have this Json output and i am calling in my android app. I am able to get picture path but how can i display picture instead of path . here is the code

public class Test extends ListActivity  {
      Prefs myprefs = null;

    @Override
    public void onCreate(Bundle savedInstanceState) {
        super.onCreate(savedInstanceState);
        setContentView(R.layout.listplaceholder);
        this.myprefs = new Prefs(getApplicationContext());
        // install handler for processing gui update messages
        ArrayList<HashMap<String, String>> mylist = new ArrayList<HashMap<String, String>>();
       JSONObject json = JSONfunctions.getJSONfromURL("http://midsweden.gofreeserve.com/proj/androidjson.php?identifier=" + 
        Test.this.myprefs.getPersonalno());

        try{

            JSONArray  earthquakes = json.getJSONArray("services");

            for(int i=0;i<earthquakes.length();i++){                        
                HashMap<String, String> map = new HashMap<String, String>();    
                JSONObject e = earthquakes.getJSONObject(i);

                map.put("id",  String.valueOf(i));
                map.put("pic", "Picture : " + e.getString("employeepic"));
                map.put("serviceinfo", "" +  e.getString("employeename")+ " : "+ e.getString("starttime")
                        +" To " +  e.getString("endtime"));
                mylist.add(map);            
            }       
        }catch(JSONException e)        {
             Log.e("log_tag", "Error parsing data "+e.toString());
        }

        ListAdapter adapter = new SimpleAdapter(this, mylist , R.layout.test, 
                        new String[] { "pic", "serviceinfo" }, 
                        new int[] { R.id.item_title, R.id.item_subtitle });

        setListAdapter(adapter);

        final ListView lv = getListView();
        lv.setTextFilterEnabled(true);  
        lv.setOnItemClickListener(new OnItemClickListener() {
            public void onItemClick(AdapterView<?> parent, View view, int position, long id) {              
                @SuppressWarnings("unchecked")
                HashMap<String, String> o = (HashMap<String, String>) lv.getItemAtPosition(position);                   
                Toast.makeText(Test.this, "ID '" + o.get("id") + "' was clicked.", Toast.LENGTH_SHORT).show(); 

            }
        });

    }

This is path which i am getting in my android app

pictures/file83915.jpg

Here i am calling picture

map.put("pic", "Picture : " + e.getString("employeepic"));
  • 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-05-23T13:05:00+00:00Added an answer on May 23, 2026 at 1:05 pm

    I have used this class for downloading image from server
    Hope it will help you…!! When you have got your image URLs list from your server or any source, then used it like this to download that particular Image.

    GetImage.downloadFile("pictures/file83915.jpg", new ImageDownloaded()
    {
        @Override
        public void imageDownloaded(Bitmap result){
            image.setImageBitmap(result);
        }
    
        @Override
        public void imageDownloadedFailed(){
        }
    
    });
    

    Where the GetImage class is:

    public class GetImage
    {
        public static void  downloadFile(final String fileUrl, final ImageDownloaded img)
        {
            AsyncTask<String , Void, Bitmap> task = new AsyncTask<String , Void, Bitmap>()
            {
                @Override
                protected Bitmap doInBackground(String... params) {
                    Bitmap bmImg;
                    URL myFileUrl =null;
                    if(fileUrl.equals(""))
                    {
                        return null;
                    }
                    try
                    {
                        myFileUrl= new URL("http://yourURl/" +fileUrl.replace(" ", "%20"));
                    }
                    catch (MalformedURLException e)
                    {
                        e.printStackTrace();
                    }
                    try
                    {
                        HttpURLConnection conn= (HttpURLConnection)myFileUrl.openConnection();
                        conn.setDoInput(true);
                        conn.connect(); 
    
                        InputStream is = conn.getInputStream();
                        bmImg = BitmapFactory.decodeStream(is);
    
                        return bmImg;
                    }
                    catch (IOException e)
                    {
                        e.printStackTrace();
                    }
                    return null;
                }
                @Override
                protected void onPostExecute(Bitmap results)
                {
                    if(results != null)
                    img.imageDownloaded(results);
                    else
                        img.imageDownloadedFailed();
                }
    
            };
            task.execute("");
    
    
        }
    
        public static abstract class ImageDownloaded
        {
            public abstract void imageDownloaded(Bitmap result);
            public abstract void imageDownloadedFailed();
        }
    
    
    }
    

    I used CustomAdapter class to show the data in the list with Images like this.
    in the method getView() I used this thread like this.

    public View getView(params....)
    {
        View row ;//Inflataion blah blah
        Bitmap thumb = myCustomObject.getBitmap();
        final ImageView image = (ImageView) row.findViewById(R.id.image);
    
        if(thumb == null)
        {
            GetImage.downloadFile(myCustomObject.getImagePath(), new ImageDownloaded()
            {
    
                @Override
                public void imageDownloaded(Bitmap result){
                    myCustomObject.setBmp(result);
                    image.setImageBitmap(myCustomObject.getBitmap());
                }
    
                @Override
                public void imageDownloadedFailed(){
                }
    
            });         
        }
        else
        image.setImageBitmap(thumb);
    }
    

    MyCustomObject is my class that encapsulates the data from server as well as Image from server and implements Parcelable interface. First I get data through JSON and then get Image in Adapter. It can also be passed to the any DetailActivity

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

Sidebar

Related Questions

Have struggled with this call for a while now but i can't get it
I have a JSON data like this: { hello: { first:firstvalue, second:secondvalue }, hello2:
Hello i have this form filling javascript: function onLine(code,nn) { document.writeform.bericht.value+=code; document.writeform.bericht.focus(); document.writeform.nickname.value+=nn; write1();
Hello I have this list that i am working on. When i move the
I have this kinda template text : Hello {#Name#}, Thanks for coming blah on
Let's say I have this string: Hello &, how are you? I'm fine! Is
i have this: <div id=parent style=overflow:auto> ... <div id=test>Hello</div> ... </div> My question is:
Suppose I have this code: String encoding = UTF-16; String text = [Hello StackOverflow];
Problem Hello all! I have this code which takes my jpg image loops through
Lets say I have this code: <?php class hello { var $greeting = hello;

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.