-1

So I'm in the beginning stages of my app and don't have a server backend yet. So for now I'm parsing the JSON from Google Places inside the App (in general I would need to do that on the server side, right?)

Since I don't have a server I generated a "Key for Server Applications" using the IP 0.0.0.0/0

My second question is, sometimes I get a "REQUEST_DENIED" when I run the following command: https://maps.googleapis.com/maps/api/place/details/json?reference=REF_NUM&sensor=true&key=MY_KEY on the phone but of-course it works when I run it on curl.

Am i doing something wrong? what doesn't it work all the time?

MoMoney
  • 1,124
  • 9
  • 11

1 Answers1

1

Could you be making too many requests per second? Try putting a one second delay between requests and see if that helps. Ultimately, the delay can probably be shorter, but starting here could help narrow down the problem.

pushbit
  • 1,268
  • 9
  • 14
  • yeah it seems to be that exactly where i run `JSONObject jsonObj2 = new JSONObject(new GetPlaces().execute(sb.toString()).get()).getJSONObject("result");` sb being the command that pulls details data and it's running in a for loop. what's the best way to delay that? – MoMoney Feb 23 '14 at 16:29
  • any idea as to what i should be doing? – MoMoney Feb 24 '14 at 20:36
  • Take a look at [Handler.postDelayed](https://developer.android.com/reference/android/os/Handler.html#postDelayed%28java.lang.Runnable,%20long%29). How many requests could you be sending at one time? I regularly send up to 20 details requests back to back and haven't had a problem. – pushbit Feb 24 '14 at 21:16
  • same, i run it for every item returned by nearbysearch which i'm assuming is defaulted to 20. – MoMoney Feb 24 '14 at 23:48
  • you know i did use Handler.postDelayed using the example [link](http://stackoverflow.com/questions/1921514/how-to-run-a-runnable-thread-in-android) where i substituted `tv.append("Hello World");` with my command `JSONObject jsonObj2 = new JSONObject(new GetPlaces().execute(sb.toString()).get()).getJSONObject("result")` but it's failing. is that the right approach? – MoMoney Feb 26 '14 at 17:03
  • any help will be greatly appreciated @pushbit. would love to just close this question – MoMoney Mar 01 '14 at 02:29
  • looks like it was just too many requests but still not too sure. i'll still check your answer :) thanks for the help – MoMoney Mar 23 '14 at 02:24