【发布时间】:2021-06-27 17:14:47
【问题描述】:
我知道 place API 需要使用服务器密钥,但我正在使用 place SDK for android。我正在使用受限的 Android API 密钥(使用包名和 SHA1 受限),但它给了我以下错误:
此 IP、站点或移动应用程序无权使用此 API 钥匙。从 IP 地址 203.122.438.42 收到的请求,为空 推荐人
作为参考,我在下面粘贴我的代码:
public PlacesSearchResponse fetch(com.google.maps.model.LatLng location) {
PlacesSearchResponse request = new PlacesSearchResponse();
GeoApiContext context = new GeoApiContext.Builder()
.apiKey(BuildConfig.MAPS_API_KEY)
.build();
try {
request = PlacesApi.nearbySearchQuery(context, location)
.radius(5000)
.keyword("Shivam")
.type(PlaceType.BAKERY)
.await();
} catch (Exception e) {
e.printStackTrace();
} finally {
return request;
//Log.d("==", "=====" + request.results[0].name);
}
}
我正在使用的依赖项:
> //To get near by locations
> implementation 'com.google.maps:google-maps-services:0.18.0'
> implementation 'com.squareup.okhttp3:okhttp:4.9.0'
【问题讨论】:
标签: android google-maps google-places-api