android - REQUEST_DENIED using Google Places API -


i developing application android using text search google places api. goal give address , latitude , longitude can mark on map. send following request google places :

https://maps.googleapis.com/maps/api/place/textsearch/json?query=46+rue+emile+raspail+arcueil&sensor=true&key=my_api_key

using code :

public class geolocrdv {      private latlng pos;      private static final string api_key = " xxxxx_my_key ";     private static final string places_text_search_url = "https://maps.googleapis.com/maps/api/place/textsearch/json?";      public geolocrdv(string rdvplace){         string url;          try {             url = places_text_search_url+"query=" + urlencoder.encode(rdvplace,"utf-8") + "&sensor=true&key=" + api_key;             log.e("debug http", url);              httpclient httpclient = new defaulthttpclient();             httpresponse response;              response = httpclient.execute(new httpget(url));             statusline statusline = response.getstatusline();              if(statusline.getstatuscode() == httpstatus.sc_ok){                 bytearrayoutputstream out = new bytearrayoutputstream();                 response.getentity().writeto(out);                 out.close();                 string responsestring = out.tostring();                  log.e("debug resp", responsestring);                  jsonobject jsonobj = new jsonobject(responsestring);                 jsonarray results = (jsonarray) jsonobj.get("results");                  log.e("debug json", results.tostring());                  double rdvlat = (double) results.getjsonobject(0).getjsonobject("geometry").getjsonobject("location").get("lat");                 log.e("debug json lat", float.tostring((float) rdvlat));                  double rdvlng = (double) results.getjsonobject(0).getjsonobject("geometry").getjsonobject("location").get("lng");                 log.e("debug json lng", float.tostring((float) rdvlng));                  this.pos = new latlng(rdvlat, rdvlng);                 log.e("debug geo", pos.tostring());              }else{                 response.getentity().getcontent().close();             }         } catch (unsupportedencodingexception e1) {             e1.printstacktrace();         } catch (clientprotocolexception e) {             e.printstacktrace();         } catch (ioexception e) {             e.printstacktrace();         } catch (jsonexception e) {             e.printstacktrace();         }     } 

unfortunately response :

{     "html_attributions" : [],     "results" : [],     "status" : "request_denied" } 

i tried :

  • switch "sensor" parameter "true" , "false"
  • change https http
  • verify key correctly copied/pasted , corresponding 1 in manifest
  • i went api console, services, clicked active services tab , verified 'places api' turned on. clicked on ? , "try out!" link next it. returned me same json (request_denied)

i read on stackoverflow try change port address 443 response places api, don't know how it.

finally, specify activated google places service after getting api key (because using maps api) , android key (not server or browser), not supposed issue since key works whole application.

i running out of ideas fix request problem, hope can me.

thanks in advance.


Comments

Popular posts from this blog

php - cannot display multiple markers in google maps v3 from traceroute result -

c# - DetailsView in ASP.Net - How to add another column on the side/add a control in each row? -

javascript - firefox memory leak -