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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 6, 20262026-06-06T09:34:40+00:00 2026-06-06T09:34:40+00:00

I am trying to request JSON data from a PHP script in my Android

  • 0

I am trying to request JSON data from a PHP script in my Android app.

The whole thing works well when I’m directly connecting my mobile phone and directly access the “real” Internet webserver. However, it doesn’t work at all using the emulator and localhost (WAMP installation). Running the script directly on the local webserver, again, gives me the expected results- only if I am calling it on the same machine using the emulator, the troubles begin.

Here are the combinations I have tried so far (the scripts are located in the subdirectory “zz” of the root):

private static String url_all_venues = "http://10.0.2.2/zz/pullvenuesjson.php";

or

private static String url_all_venues = "http://10.0.2.2:80/zz/pullvenuesjson.php";

leads to the following exception: E/JSON Parser(657): Error parsing data org.json.JSONException: Value

When I’m trying the following:

private static String url_all_venues = "http://10.0.2.2:8080/zz/pullvenuesjson.php";

the code runs ‘forever’ and I’m getting a timeout error after about 5 minutes.

Any idea how to fix that so I can also test my app on my local webserver / the emulator? Most probably the problem is in my local Apache configuration, but then, I’m not sure…

EDIT:

Here is some of the code that seems to trigger the error:

            DefaultHttpClient httpClient = new DefaultHttpClient();
            String paramString = URLEncodedUtils.format(params, "utf-8");
            url += "?" + paramString;
            HttpGet httpGet = new HttpGet(url); 
            HttpResponse httpResponse = httpClient.execute(httpGet);
            HttpEntity httpEntity = httpResponse.getEntity();
            is = httpEntity.getContent();

“url” is the one mentioned above. As mentioned in my comment below, it looks as if the problem comes from the local WAMP webserver not responding appropriately, since the code works fine when I’m directly accessing the “real” server via the Internet (i.o.w, do nothing else than changing the URL to the Internet address of the php script). The odd thing is that the script also works fine when I run it locally, but NOT through the emulator.

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

    I finally figured it out! I logged the transferred data using Log.d(..) and found out that the username/password combination was not valid as I didn’t check for the localhost condition… The script and app retrieves the data just fine now on both, localhost and the web. Thanks for your inquiries which helped me to get down to the root of the error!

    [Answered myself in order to avoid the Q showing up as unanswered]

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

Sidebar

Related Questions

I'm trying to cache JSON content generated by a php script from database. However
I'm trying to get a property from JSON data decoded into a PHP object.
I'm trying to use Request.JSON in mooTools to bring in an object from a
I'm trying to grab some JSON from Apple's iTunes JSON service. The request is
I am trying to populate a UITableView with data from json result. I can
I am trying to use dojo.xhrGet to get some json back from a php
I am trying to send JSON data from a form using the XMLHttpRequest object.
Im trying to retrieve some data from JSON object which holds location information such
I am trying to make an asynchronous request to get some data from my
I'm trying to parse some JSON coming from an AJAX request using jQuery. Basically,

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.