Google Mapsplace Picker启动后立即关闭

时间:2019-03-02 13:09:47

标签: android google-maps

当尝试在onclick内创建android位置选择器

PlacePicker.IntentBuilder builder = new PlacePicker.IntentBuilder();
            try {

                Intent intent = builder.build(this);
                startActivityForResult(intent, PLACE_PICKER_REQUEST);
            } catch (GooglePlayServicesRepairableException e) {
                e.printStackTrace();
            } catch (GooglePlayServicesNotAvailableException e) {
                e.printStackTrace();
            }

位置选择器在第二秒后立即打开和关闭 我加了清单

<meta-data
        android:name="com.google.android.geo.API_KEY"
        android:value="@string/google_maps_key" />

并与我的控制台相连,仍然有相同的问题

1 个答案:

答案 0 :(得分:0)

此地点选择器已弃用,您需要使用新的地点选择器 在您的应用程序级别gradle中使用它  实施'com.google.android.libraries.places:places:1.0.0'

CoreData: error: SQLCore dispatchRequest: exception handling request: <NSSQLFetchRequestContext: 0x600000a34a80> , to-many key not allowed here with userInfo of (null)

在您的活动结果中

 try {
                Places.initialize(Objects.requireNonNull(this), "YOUR_KEY");
                PlacesClient placesClient = Places.createClient(this);
                List<Place.Field> placeFields = Arrays.asList(Place.Field.ADDRESS,
                        Place.Field.ID,
                        Place.Field.PHONE_NUMBER,
                        Place.Field.LAT_LNG);
                Intent intent = new Autocomplete.IntentBuilder(
                        AutocompleteActivityMode.FULLSCREEN, placeFields)
                        .build(this);
                startActivityForResult(intent, PLACE_PICKER_REQUEST);
            } catch (Exception e) {
                e.printStackTrace();
            }