当我尝试按地址获取 GPS 坐标时,我应该在哪里添加 Google API 密钥?



我想我把我的地图谷歌api密钥添加到了错误的地方。请帮助我:

相关的 api 密钥还更新了资源:

<string name="google_maps_key" templateMergeStrategy="preserve" translatable="false">AIzaSyAzSgqQEZ..........KMsLlN4</string>

@Override
protected String doInBackground(String... strings) {
String response;
try {
String address = strings[0];
HttpDataHandler http = new HttpDataHandler();
String url = String.format("http://maps.googleapis.com/maps/api/geocode/json?address=%s&key=AIzaSyAzSgqQEZS1K1...........KMsLlN4", address);
response = http.getHTTPData(url);
return response;
} catch (Exception ex) {
}
return null;
}

我没有得到任何结果,我认为我的访问权限仍然被拒绝...... 我应该把它放在哪里?

来自官方文档->

got to the gradle.properties file and add a value with name GOOGLE_MAPS_API_KEY="your api key" and rebuild project.After in your manifest file you will see api key.

附言不要忘记权限

解决方案是在Google Api控制台中启用地理编码API,并仅限于特定应用程序!!

最新更新