简体   繁体   中英

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

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.

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.

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. 在此处输入图片说明

Please see this image.

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM