gpt4 book ai didi

android - 如何使用地点 ID(最新)获取地点?

转载 作者:行者123 更新时间:2023-11-29 22:57:36 29 4
gpt4 key购买 nike

谁能给我一些使用地点 ID 获取地点的示例?并获取地点信息?我无法按照谷歌的教程进行操作

我无法按照此链接中的谷歌教程进行操作。 here's the link about the latest google place

最佳答案

为什么不能关注Google's migration guide ?如果您尚未迁移,请尽快迁移,因为旧的 Places SDK for Android 已被弃用。

关于如何通过地点ID获取地点详情,可以使用fetchPlace()方法。

看看Google's code example下面:

// Define a Place ID.
String placeId = "INSERT_PLACE_ID_HERE";

// Specify the fields to return.
List<Place.Field> placeFields = Arrays.asList(Place.Field.ID, Place.Field.NAME);

// Construct a request object, passing the place ID and fields array.
FetchPlaceRequest request = FetchPlaceRequest.newInstance(placeId, placeFields);

placesClient.fetchPlace(request).addOnSuccessListener((response) -> {
Place place = response.getPlace();
Log.i(TAG, "Place found: " + place.getName());
}).addOnFailureListener((exception) -> {
if (exception instanceof ApiException) {
ApiException apiException = (ApiException) exception;
int statusCode = apiException.getStatusCode();
// Handle error with given status code.
Log.e(TAG, "Place not found: " + exception.getMessage());
}
});

希望这可以帮助您入门!

关于android - 如何使用地点 ID(最新)获取地点?,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/57277438/

29 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com