which api key to get for autocomplete textview to show places in google maps?

942 views Asked by At

in my app i am using google maps with pickup and drop place search box on top.I am using autocomplete textview based on the following links https://github.com/seatgeek/android-PlacesAutocompleteTextView.now i am going to release my apk. my code is repositories { mavenCentral() maven(){ url "https://oss.sonatype.org/content/repositories/snapshots" } } compile 'com.seatgeek:placesautocomplete:0.2-SNAPSHOT' xml file is:

    app:pacv_historyFile="@string/pacv_default_history_file_name"
    app:pacv_googleMapsApiKey="AIzaSyCDtiMxC1BvScyGOFibjo16MPFe-eQcGRE"/>

protected void onCreate(Bundle savedInstanceState) {
    super.onCreate(savedInstanceState);
    setContentView(R.layout.activity_main);

    PlacesAutocompleteTextView placesAutocomplete=(PlacesAutocompleteTextView)findViewById(R.id.places_autocomplete);


    placesAutocomplete.setOnPlaceSelectedListener(
            new OnPlaceSelectedListener() {
                @Override
                public void onPlaceSelected(final Place place) {
                    // do something awesome with the selected place
                }
            }
    );

what i did:: i go to google API CONSOLE and enabled google maps places api for android.i didnot add any restrictions and then i got a api key with yellow color warning mark.i paste it in the xml file at " app:pacv_googleMapsApiKey="AIzaSyCDtiMxC1BvScyGOFibjo16MPFe-eQcGRE"/> ".

mydoubt:: my autocomplete textview is working properly showing suggestions while i am testing.my doubt is that when i release apk in playstore it will work or not.please help me.

2

There are 2 answers

3
Rishabh Mahatha On

Key will be same(Your product key) just enable google place web service api in your project from google console.If you are using auto complete text view else you can also use the new placeAutoCompleteFragment or google place picker api(New).

http://www.truiton.com/2015/04/using-new-google-places-api-android/

This link is for google place picker.

3
bharat7777 On

If you do not add any restriction when it will not effect. In case you really want to put restriction for API key then you should add "Package name : fingerprint" so any app will not have match with this. So after that this key will only associated with your application.enter image description here

Please see this image.