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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 23, 20262026-05-23T02:55:59+00:00 2026-05-23T02:55:59+00:00

My build is Android 2.2 Google API 8 , Im running from the emulator.

  • 0

My build is Android 2.2 Google API 8 , Im running from the emulator. I am trying try access Location long in this JSON Object. I get this after I use

 InputStream instream = entity.getContent();

 JSONObject myAwway = new JSONObject(convertStreamToString(instream));

Google docs says it returns an array but with the surrounding curly braces It looks like an object.

I need to access lat and lon in the location field and store as doubles.

Ive searched but only seem to find help with simple files.

{
   "results" : [
      {
         "address_components" : [
            {
               "long_name" : "20059",
               "short_name" : "20059",
               "types" : [ "postal_code" ]
            },
            {
               "long_name" : "Washington D.C.",
               "short_name" : "Washington D.C.",
               "types" : [ "locality", "political" ]
            },
            {
               "long_name" : "District of Columbia",
               "short_name" : "DC",
               "types" : [ "administrative_area_level_1", "political" ]
            },
            {
               "long_name" : "United States",
               "short_name" : "US",
               "types" : [ "country", "political" ]
            }
         ],
         "formatted_address" : "Washington D.C., DC 20059, USA",
         "geometry" : {
            "bounds" : {
               "northeast" : {
                  "lat" : 38.924920,
                  "lng" : -77.0178720
               },
               "southwest" : {
                  "lat" : 38.9189910,
                  "lng" : -77.02261200000001
               }
            },
            "location" : {
               "lat" : 38.92177780,
               "lng" : -77.01974260
            },
            "location_type" : "APPROXIMATE",
            "viewport" : {
               "northeast" : {
                  "lat" : 38.92510312068017,
                  "lng" : -77.01709437931984
               },
               "southwest" : {
                  "lat" : 38.91880787931983,
                  "lng" : -77.02338962068018
               }
            }
         },
         "types" : [ "postal_code" ]
      }
   ],
   "status" : "OK"
}
  • 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-23T02:56:00+00:00Added an answer on May 23, 2026 at 2:56 am
    JSONObject location = myAwway.getJSONArray("results").getJSONObject(0).getJSONObject("geometry").getJSONObject("location");
    double lat = location.getDouble("lat");
    double lng = location.getDouble("lng");
    

    The ‘results’ JSONArray is probably the array Google docs suggested. They had just wrapped it up in a JSONObject with a status, so that you could check the status before attempting to work on the returned value.

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

Sidebar

Related Questions

I'm trying to compile and run the task-android-sample code from Google's API website. I
I am trying to run the Task-Android-sample given at Google Api Java Client I
While trying the google plus API example from the project site I'm completely stuck
I'm trying to build an android app that would do a local search on
I'm trying to build a custom clock view in Android. See image http://twitpic.com/1devk7 So
At the moment I'm trying to build some integration tests for an android project.
I am trying to build my Android project with Ant. Whenever I use Eclipse
Possible Duplicate: Android Emulator - Trouble creating user accounts I'm trying to register a
I am trying to build sipdroid under eclipse,I have downloaded the source from the
I just created a project with google api build target (API level 3) in

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.