AutoComplete Google Places get error :This API project is not authorized to use this API. Please ensure that this API is activated in the APIs Console

余生颓废 提交于 2019-12-02 07:13:07

I see you're using the Places API Web Service — you may find the Places API for Android suits you better as you're writing an Android app. The Places API for Android will allow you to use an Android key, which can be restricted to be only usable by your app, unlike Server keys.

For using the Web Service follow the Get a Key instructions in the Developer's Guide. In particular make sure that you:

  • Use a Server key, and
  • Have enabled Google Places API Web Service (not the same as Google Places API for Android) in the Google Developers Console.

Go https://code.google.com/apis/console login with your id, Create an application put all detail and generate API Key and put your API key in below code
// String key = "Put your API key here ";

private String getAutoCompleteUrl(String place){

        // Obtain browser key from https://code.google.com/apis/console
        String key = "Put your API key here "; here you update your key
    // 

        // place to be be searched
        String input = "input="+place;

        // place type to be searched
        String types = "types=geocode";

        // Sensor enabled
        String sensor = "sensor=false";

        // Building the parameters to the web service
        String parameters = input+"&"+types+"&"+sensor+"&"+key;

        // Output format
        String output = "json";

        // Building the url to the web service
        String url = "https://maps.googleapis.com/maps/api/place/autocomplete/"+output+"?"+parameters;

        return url;
    }
易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!