google-place-api返回null json

在我的应用程序中我想使用google place api来获取最近的地方,如atm, Bus 站等...但它返回null结果.. url is

https://maps.googleapis.com/maps/api/place/nearbysearch/json?location=28.568315675,77.33492885&radius=5000&types=ATM&sensor=false&key=AIzaSyAryW3R30sFQCsDb3wQR_EeiZ_dAvyUilQ

和代码是::

String data = "";
    InputStream iStream = null;
    HttpURLConnection urlConnection = null;
    try{
            URL url = new URL(strUrl);                



            urlConnection = (HttpURLConnection) url.openConnection();                


            urlConnection.connect();                


            iStream = urlConnection.getInputStream();

            BufferedReader br = new BufferedReader(new InputStreamReader(iStream));

            StringBuffer sb  = new StringBuffer();

            String line = "";
            while( ( line = br.readLine())  != null){
                    sb.append(line);
            }

            data = sb.toString();

            br.close();

    }catch(Exception e){
            Log.d("Exception while downloading url", e.toString());
    }finally{
            iStream.close();
            urlConnection.disconnect();
    }
    return data;

我hv参考了许多链接,但没有锦鲤帮助milii ....

How can I search places with specific types using Google Places API?

finding both "Shopping_mall" and "food" within single URL for google places API

回答(1)

2 years ago

你使用键,即Android应用程序的密钥..而不是浏览器应用程序的密钥..使用dis ..它一定会运行... gud运气