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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 8, 20262026-06-08T09:34:24+00:00 2026-06-08T09:34:24+00:00

In the below code, I can display the first returned JSON place name result

  • 0

In the below code, I can display the first returned JSON place name result from my Google Places URL. Rather than just the first item, I’d like to display the whole returned list of place names. What would be the easiest way of doing this? Can you point me to a tutorial, or give sample code?

        HttpGet get = new HttpGet(bcURL.toString());
    HttpResponse r = client.execute(get);
    int status = r.getStatusLine().getStatusCode();
    if(status == 200){
        HttpEntity e = r.getEntity(); 
        String data = EntityUtils.toString(e); 
        json = new JSONObject(data); 
        JSONArray timeline = json.getJSONArray("results"); 
        JSONObject lastport = timeline.getJSONObject(0); 
        return lastport;
    }else{
        Toast.makeText(NewGPS3.this, "oops", Toast.LENGTH_SHORT);
        return null;
    }

The line JSONObject lastport = timeline.getJSONObject(0); shows the first name. I’d like to show a list rather than just the first item.

  • 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-08T09:34:27+00:00Added an answer on June 8, 2026 at 9:34 am

    You are going to need to use a JSONArray object in order to get at the array. It should go something like this:

    JSONObject entireObject = new JSONObject("your JSON string here");
    JSONObject mainObject = entireObject.getJSONObject("photos"); // main object in entire object
    JSONArray arrayObject = mainObject.getJSONArray("photo"); // array object in the main object
    

    You can then iterate through this array just like any other:

    for (int i = 0; i < arrayObject.length(); i++) {
        JSONObject photoData = arrayObject.getJSONObject(i);
        String yourString = photoData.getString("id");
    }
    

    I got some of this out of Pro Android Media. There is a really good JSON api call example in this book. You can probably get the source code for free, too.

    http://www.amazon.com/Pro-Android-Media-Developing-Smartphones/dp/1430232676/ref=sr_1_1?ie=UTF8&qid=1343062690&sr=8-1&keywords=android+media

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

Sidebar

Related Questions

The code below working for only first div. I can't display other divs when
The code below first displays folders as hyperlinks, you can click into these folders
I'm using the code provided below to display time and date. can anyone help
From the disassembly code below can I assume that the location 43E010 is a
I'm trying to parse Google Places JSON data in Android. I know the URL
In past, I am using Listview and using below code can show a particular
It is a compiler error or runtime error? The code below can be compiled!
Using the code below I can insert a new row to my table (
How can the code below be modified, such that I can use the arrow
W.r.t code below I can not declare the type of fetch-into-variable as the underlying

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.