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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 11, 20262026-06-11T00:14:02+00:00 2026-06-11T00:14:02+00:00

I am a noob to android and i want to parse a google response

  • 0

I am a noob to android and i want to parse a google response JSON with the same formatting as the example here: https://developers.google.com/places/documentation/details. I’m trying to get the string formatted phone number. However, when i code to .getString from the array “events” my editor asks for a int index. I don’t understand what is going on. Any help is greatly appreciated. Here is my code:

try {   
        JSONObject googleObject = StoresNearMe.getJSONfromURL(googleplacedetailapi);
        JSONObject parsedGoogle = googleObject.getJSONObject("results");
        JSONArray  parsedevents = parsedGoogle.getJSONArray("events");
        //thing.setText(googleplacesapi);
        if(parsedevents.equals("") ){
            Toast.makeText(FindDealer.this, "No nearby locations", Toast.LENGTH_LONG).show();
        }else{
            String phonenumber = parsedevents.getString("formatted_phone_number");
            thing.setText(phonenumber);   
      }            
  } catch (JSONException e) {
      Log.d("log_tag","JSON parsing error - Google Places Api:" + e.getMessage());
  }      
  • 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-11T00:14:04+00:00Added an answer on June 11, 2026 at 12:14 am

    formatted_phone_number is in results json object, not in events json array.

    Change the line:

    String phonenumber = parsedevents.getString("formatted_phone_number");
    

    to

    String phonenumber = parsedGoogle.getString("formatted_phone_number");
    

    You might read something about json structure on json.org.

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

Sidebar

Related Questions

noob Android/JSON person here. I hope someone might help me? I've looked and looked
Noob question for Ruby on Rails- here's an example of my situation: If I
Android and Java noob here, although I've dabbled in various languages over the years.
I've read dozens of post (here and other places) asking for parsing from/to JSON
Android and libgdx noob here. Does anyone know anything about the recent UI API
I'm a noob to android and I'm trying to learn how to parse xml
Java/Android noob here (Still) I hoped you could help. I was trying to add
I am a noob learning android and building a simple game at the same
http://code.google.com/p/apps-for-android/ I have eclipse setup with Subversive plugin, I can download the codes down
android noob... I have two tables, with a one to many relationship between country_tbl

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.