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

前端 未结 2 1391
轮回少年
轮回少年 2021-01-24 03:17

i\'m trying to develop Maps with autocomplete textview with Google API.

i tried this tutorial here

but i always get this error when i\'m tryin to get the API : <

相关标签:
2条回答
  • 2021-01-24 03:44

    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.
    0 讨论(0)
  • 2021-01-24 03:58

    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;
        }
    
    0 讨论(0)
提交回复
热议问题