Reputation: 753
I am working on an application which uses google places API.
I got API key for my application,but the problem is I am getting ZERO_RESULTS
as a response from the sever.
Here is my code I used DefaultHttpClient
to establish the http connection. Can anyone tell me what is the problem?
Please help I am stuck here.
public class Splash extends Activity{
private String keystring="";
//This is my request url
String requesturl="https://maps.googleapis.com/maps/api/place/search/json?" +
"location=17.739290150000002,83.3071201&radius=6000&" +
"types=hospital&sensor=false&key=";
private static byte[] key;
String signaturegot;
@Override
protected void onCreate(Bundle savedInstanceState) {
// TODO Auto-generated method stub
super.onCreate(savedInstanceState);
/*
Here I am using default http client to establish
the connection for the request url
*/
HttpClient client=new DefaultHttpClient();
StringBuilder builder=new StringBuilder(requesturl);
builder.append(URLEncoder.encode(keystring));
HttpPost post=new HttpPost(requesturl);
try {
HttpResponse response=client.execute(post);
HttpEntity entity=response.getEntity();
if (entity != null) {
InputStream is = entity.getContent();
String val = StaticUtils.convertStreamToString(is);
Log.e("",val);
}
} catch (ClientProtocolException e) {
e.printStackTrace();
} catch (IOException e) {
e.printStackTrace();
}
}
Here is the response from the server
{
"html_attributions" : [],
"results" : [],
"status" : "ZERO_RESULTS"
}
Upvotes: 3
Views: 976
Reputation: 33792
Due to some weird reason, for locations in India, instead of using types
use names
For the phone number, you have to request details using the reference string that you got from the above URL :
The output will contain:
"formatted_phone_number" : "0891 123 0101",
"geometry" : {
"location" : {
"lat" : 17.7060120,
"lng" : 83.3104410
}
},
Upvotes: 1