Wednesday, April 3, 2013

Google Places Api is giving me request denied always



j.setUrl("https://maps.googleapis.com/maps/api/place/nearbysearch/json?location=-33.8670522,151.1957362&radius=500&types=food&name=harbour&sensor=false&key=AIzaSyA712jyN6NY0VXSGf8zgXfXSRhq01O8RLY");


This is my json url with my key. It always gives me status request denied . I have tried making alot of keys with debug keystore and new keystores but nothing works . it is the example url of google. It doesn't work for me. If you want to provide a solution regarding a new key please give me the detailed procedure on how to get a valid debug key. Please be very detailed. If you want to provide a solution regarding sensor paramater its there already. If you want json parser file its as below



package com.json;

import java.io.BufferedReader;
import java.io.IOException;
import java.io.InputStream;
import java.io.InputStreamReader;
import java.io.UnsupportedEncodingException;

import org.apache.http.HttpEntity;
import org.apache.http.HttpResponse;
import org.apache.http.client.ClientProtocolException;
import org.apache.http.client.methods.HttpPost;
import org.apache.http.impl.client.DefaultHttpClient;
import org.json.JSONException;
import org.json.JSONObject;

import android.os.AsyncTask;
public class JSONParser extends AsyncTask {

static InputStream is = null;
static JSONObject jObj = null;
static String json = "";
private String url;

// constructor
public JSONParser() {

}

@Override
protected JSONObject doInBackground(Void... params) {
// defaultHttpClient
DefaultHttpClient httpClient = new DefaultHttpClient();
HttpPost httpPost = new HttpPost(getUrl());

HttpResponse httpResponse = null;
try {
httpResponse = httpClient.execute(httpPost);
} catch (ClientProtocolException e2) {
// TODO Auto-generated catch block
e2.printStackTrace();
} catch (IOException e2) {
// TODO Auto-generated catch block
e2.printStackTrace();
}
HttpEntity httpEntity = httpResponse.getEntity();
try {
is = httpEntity.getContent();
} catch (IllegalStateException e) {
// TODO Auto-generated catch block
e.printStackTrace();
} catch (IOException e) {
// TODO Auto-generated catch block
e.printStackTrace();
}

BufferedReader reader = null;
try {
reader = new BufferedReader(
new InputStreamReader(is, "iso-8859-1"), 8);
} catch (UnsupportedEncodingException e) {
// TODO Auto-generated catch block
e.printStackTrace();
}
StringBuilder sb = new StringBuilder();
String line = null;
try {
while ((line = reader.readLine()) != null) {
sb.append(line + "\n");
}
} catch (IOException e1) {
// TODO Auto-generated catch block
e1.printStackTrace();
}
try {
is.close();
} catch (IOException e) {
// TODO Auto-generated catch block
e.printStackTrace();
}
json = sb.toString();

try {
jObj = new JSONObject(json);
} catch (JSONException e) {
// TODO Auto-generated catch block
e.printStackTrace();
}

// return JSON String
return jObj;
}

public String getUrl() {
return url;
}

public void setUrl(String url) {
this.url = url;
}


}



.

forum.xda-developers.com

No comments:

Post a Comment

Google Voice on T-Mobile? [General]

Google Voice on T-Mobile? So I recently switched from a GNex on Verizon to a Moto X DE on T-Mobile. I had always used Google Voice for my v...