read thru all the posts on this subject and tried out all the combination : 1. used the android key while making the google places API call ( 2. switched to browser key 3. later tried with server key. 4. re-generated the keys and tried the combination 1-3.
Nothing is working !!. My key for the Mapv2 API in the manifest file is the android key. This app was working correctly until I created a new project and listed my package with the new project. I recreated new android key for this package. The old key was still there but with a different project. I have not deleted the old project but removed all the key under it. so now I have new keys for android, browser under a new project. am I doing it wrong?.
I get the error message as " Provided API key is invalid"... when I make this call from the browser using the browser key it is working . Not not from my android app . any tips ?.
Please see the code below:-
final String PLACES_API_BASE = "https://maps.googleapis.com/maps/api/place/nearbysearch";
final String OUT_JSON = "/json";
final String KEY=<browser-key>
final String SENSOR="false";
StringBuilder querystring = new StringBuilder(PLACES_API_BASE+OUT_JSON);
try{
querystring.append("?sensor="+SENSOR+"&key="+KEY);
String localquery="&location=37.316318,-122.005916&radius=500&name=traderjoe";
querystring.append(URLEncoder.encode(localquery, "UTF-8"));
URL url = new URL(querystring.toString());
HttpURLConnection connection = (HttpURLConnection)url.openConnection();
connection.setRequestMethod("GET");
String line;
StringBuilder builder = new StringBuilder();
BufferedReader reader = new BufferedReader(
new InputStreamReader(connection.getInputStream()));
while((line = reader.readLine()) != null) {
builder.append(line);
}
System.out.println("JSON BUILDER INPUT FROM GOOGLE PLACES QUERY="+builder.toString());
This is where I get the error message:- Provided APi Key is invaild