gpt4 book ai didi

java - 当我在 androidX 中导入 Migrating to the New Places SDK Client 时。无法访问 getPhotoMetadatas() 方法

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

我正在尝试迁移到 New Places SDK Client 并导入此“implementation 'com.google.android.libraries.places:places:2.0.0'”库并导入“implementation 'com.google.android.libraries .places:places-compat:2.0.0'"在 app base gradle 中导入两个库之后。

我想从谷歌地图获取位置照片请谁帮我如何从谷歌地图获取照片?

提前致谢....

我正在尝试访问获取地点照片方法,使用 get place.getPhotoMetadatas() 从谷歌地图位置获取照片。

placesClient.fetchPlace(placeRequest).addOnSuccessListener((响应) -> { 地点 place = response.getPlace();

// Get the photo metadata.
PhotoMetadata photoMetadata = place.getPhotoMetadatas().get(0);

// Get the attribution text.
String attributions = photoMetadata.getAttributions();

// Create a FetchPhotoRequest.
FetchPhotoRequest photoRequest = FetchPhotoRequest.builder(photoMetadata)
.setMaxWidth(500) // Optional.
.setMaxHeight(300) // Optional.
.build();
placesClient.fetchPhoto(photoRequest).addOnSuccessListener((fetchPhotoResponse) -> {
Bitmap bitmap = fetchPhotoResponse.getBitmap();
imageView.setImageBitmap(bitmap);
}).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());
}
});

});

无法解析方法 place.getPhotoMetadatas()

最佳答案

导入此“实现'com.google.android.libraries.places:places:2.0.0'”库并更新应用程序 gradle 文件的所有库。并将 android 项目转换或迁移到 androidX。

关于java - 当我在 androidX 中导入 Migrating to the New Places SDK Client 时。无法访问 getPhotoMetadatas() 方法,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/58254495/

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