相关疑难解决方法(0)

如何实现PlaceAutocompleteFragment和PlaceAutocompleteActivity以获取Place详细信息

我正在使用Google Place来获取地点详细信息.Google提供了不同的方式来实现Google Place API以获取地点详细信息.不同的方式是PlaceAutocompleteFragment,PlaceAutocompleteActivity.如何区分这些全部以及如何使用Google Place API获取地点详细信息.

android google-places-api google-play-services

10
推荐指数
1
解决办法
3万
查看次数

PlaceAutocompleteFragment无法解决

在我的应用中,我添加了Google地图,它们运行正常.我想添加一个PlaceAutocompleteFragment.我正在使用我已经为地图生成的密钥,我已经启用了google.console中的Places Api选项.我已将这些添加到我的build.gradle中:

compile 'com.google.android.gms:play-services-maps:8.3.0'
compile 'com.google.android.gms:play-services-location:8.3.0'
compile 'com.google.android.gms:play-services:8.3.0'
Run Code Online (Sandbox Code Playgroud)

但是当我尝试使用PlacesAutoCompleteFragment时,Android Studio无法解决此问题.

android google-places-api

4
推荐指数
1
解决办法
5412
查看次数

Google Places API AutocompleteSupportFragment空指针异常

我正在使用Google Places API来获取自动完成支持片段,以获取带有位置建议的搜索栏。我跟着这里给出的教程 商家信息自动填充

这是XML代码

<fragment
            android:id="@+id/autoCompleteFragment"
            android:layout_width="match_parent"
            android:layout_height="match_parent"
            android:name="com.google.android.libraries.places.widget.AutocompleteSupportFragment" />
Run Code Online (Sandbox Code Playgroud)

这是Java代码

// Initialize the AutocompleteSupportFragment.
    AutocompleteSupportFragment autocompleteFragment = (AutocompleteSupportFragment) getActivity().getSupportFragmentManager().findFragmentById(R.id.autoCompleteFragment);

    // Specify the types of place data to return.
    autocompleteFragment.setPlaceFields(Arrays.asList(Place.Field.ID, Place.Field.NAME));

        // Set up a PlaceSelectionListener to handle the response.
    autocompleteFragment.setOnPlaceSelectedListener(new PlaceSelectionListener() {
        @Override
        public void onPlaceSelected(Place place) {
            // TODO: Get info about the selected place.
            Log.i(TAG, "Place: " + place.getName() + ", " + place.getId());
        }
        @Override
        public void onError(Status status) {
            // TODO: Handle the error. …
Run Code Online (Sandbox Code Playgroud)

android google-places-api google-places-autocomplete

3
推荐指数
1
解决办法
1103
查看次数