Take the 2-minute tour ×

I want to develop an application in which i want to display information about places nearby (within 1km )the user by getting its current location..

Say for example i want to display information about Restaurants, Shopping Malls, Hospitals located within 1km related to current location of the android device..

I have gone through this link : Using Google Places API in Android.. But didnt get more.

Have anyone used Google Places API in android ?

share|improve this question
Have you gone through the tutorial link in the answer of the question Google Places API in Android? –  Harry Joy Apr 22 '11 at 6:52
Yes. That's what i have wrote in question only. –  Kartik Apr 22 '11 at 6:53
What problem you face in following the tutorial? Do you get any error? –  Harry Joy Apr 22 '11 at 6:56
@Harry Joy : i am not getting the terms given in UrlSigner class .. how to implement this thing ? –  Kartik Apr 22 '11 at 7:00
Which terms? keyString and urlString? –  Harry Joy Apr 22 '11 at 7:01
show 6 more comments

5 Answers

up vote 15 down vote accepted

Try this tutorial: using-googles-places-api and wherever you get problem ask it in comment.

Some points to keep in mind:

  • In order to use Google’s Places API, you will need to register and obtain a Google Map’s API Key.
  • In class UrlSigner in the tutorial the variable descriptions are: keyString=> its your google map api key. urlString=>its the url you wanna sign using the api key.
  • In code you will find inputKey and inputUrl. these 2 variables are just for testing purpose you can omit them if you want. You can directly write code as follows:

    URL url = new URL(urlString);

    UrlSigner signer = new UrlSigner(keyString);

    String request = signer.signRequest(url.getPath(),url.getQuery());

    System.out.println("Signed URL :" + url.getProtocol() + "://" + url.getHost() + request);

in main method of UrlSigner class.

share|improve this answer
i dont have google adsense account. Its compulsory to have google adsense account ?. When i was going thru some google's documents they recommended this. –  Kartik Apr 28 '11 at 4:31
@Kartik: No. You just need to be signed in in gmail. –  Harry Joy Apr 28 '11 at 4:34
thank you...m trying this today.. –  Kartik Apr 28 '11 at 4:38
@Kartik: good. Best of luck.;-) –  Harry Joy Apr 28 '11 at 4:39
add comment

The API works well in India(of-course will work anywhere in the globe). What you must go through is Google Places API. You can simply give a url request to google with user's current location and place-types that you would prefer.

The response may be either XML or Json as per your request. All you have to do is parse it out. You can get places around you upto 50 kms. An example for url request is


*Note: %7C is just "|".

share|improve this answer
add comment

The Google Places API went public a couple of weeks ago.

Using the Android compatible Google APIs Client Library for Java, you can use the Google Places API from an Android runtime.

The Google Places API REST API is well documented. For an example on using the Google APIs Client Library for Java and the Google Places API, checkout the following blog entry:


share|improve this answer
@ddewaele... i went through the link for your blog and also downloaded the code. But I am not getting why there is no res, android manifest files and folders? And what is pom.xml. Why do you create it. Please explain –  Rashmi.B Jul 7 '11 at 12:51
As mentioned in the answer, the sample only covers the Google APIs Client Library for Java and the Google Places API. It can be embedded in an Android application without many changes. –  ddewaele Jul 8 '11 at 5:53
Thanks for the humble reply ddewaele..I am a beginner in android and I am working on a bank locator. Could you help me about how do I go next after detecting my current location?what are the prerequisites for developing this locator app? –  Rashmi.B Jul 9 '11 at 12:28
I would suggest writing a new question to clearly describe what you want to do, what you have already tried, and where it went wrong. –  ddewaele Jul 11 '11 at 5:05
add comment

Keep in mind, that tutorial was written almost a year ago. The Places API has been launched to the public since then, so the registration process is now much simpler - see the documentation at: http://code.google.com/apis/maps/documentation/places/#Limits

There are also new features available now, including search by category, with over 100 different categories offered, and an Autocomplete service: http://code.google.com/apis/maps/documentation/places/autocomplete.html

In particular, the category search should help you finding restaurants, shopping malls & hospitals specifically.

share|improve this answer
add comment
For google api key:-
login to your mail account
go to https://code.google.com/apis/console/
goto services tab
click on places api and google map api button. Fill the details
goto api access tab and copy your google api key

package com.example.jstest;

import java.io.BufferedReader;
import java.io.IOException;
import java.io.InputStream;
import java.io.InputStreamReader;
import org.apache.http.HttpEntity;
import org.apache.http.HttpResponse;
import org.apache.http.StatusLine;
import org.apache.http.client.ClientProtocolException;
import org.apache.http.client.methods.HttpGet;
import org.apache.http.impl.client.DefaultHttpClient;
import org.json.JSONArray;
import org.json.JSONException;
import org.json.JSONObject;
import android.os.Bundle;
import android.app.Activity;
import android.widget.Toast;

public class MainActivity extends Activity {
    private String googleAPIKey = "your google api key"; 
    DefaultHttpClient client;
    HttpResponse res;
    HttpGet req;
    InputStream in;
    JSONObject jsonobj;
    JSONArray resarray;
    String requesturl;
    HttpEntity jsonentity;

    final String TAG = getClass().getSimpleName();  

    protected void onCreate(Bundle savedInstanceState) {


        System.out.println("Request "+requesturl);
        client=new DefaultHttpClient();

        req=new HttpGet(requesturl);

        try {
            StatusLine status = res.getStatusLine();
            int code = status.getStatusCode();
                System.out.println("Request Has not succeeded");

            in = jsonentity.getContent();

            jsonobj=new JSONObject(convertStreamToString(in));

            resarray = jsonobj.getJSONArray("results");

                int len=resarray.length();
        } catch (ClientProtocolException e) {
        } catch (IOException e) {
        catch (JSONException e) {

    private String convertStreamToString(InputStream in) {
        StringBuilder jsonstr=new StringBuilder();
        String line;
        try {
                String t=line+"\n";
        } catch (IOException e) {
        return jsonstr.toString();

share|improve this answer
add comment

Your Answer


