android - 谷歌地图地理定位 api : access not configured

标签 android geolocation google-maps-android-api-2

我正在尝试在 Android 上使用 google geolocation api。我确定我有适用于 android 的有效 apikey,并且我已经启用了计费功能。 然而,服务器返回

领域:使用限制 原因:访问未配置 代码:403

谁能解决这个问题? PS:我没有对谷歌地图开发的企业支持。下面列出了我的代码

JSONObject holder = new JSONObject();  
JSONArray cellarray = new JSONArray();  
JSONArray wifiarray = new JSONArray();
JSONObject cell = new JSONObject();
JSONObject wifi1 = new JSONObject();
JSONObject wifi2 = new JSONObject();
try {
    cell.put("cellId", cid);
    cell.put("locationAreaCode", lac); 
    cell.put("mobileCountryCode", mcc);  
    cell.put("mobileNetworkCode", mnc);
    cell.put("age", 0);
    cell.put("signalStrength", -95);
    cellarray.put(cell);

    wifi1.put("macAddress", "01:23:45:67:89:AB");
    wifi1.put("signalStrength", 8);
    wifi1.put("age", 0);
    wifi1.put("signalToNoiseRatio", -65);
    wifi1.put("channel", 8);
    wifiarray.put(wifi1);

    wifi2.put("macAddress", "01:23:45:67:89:AC");
    wifi2.put("signalStrength", 4);
    wifi2.put("age", 0);
    wifiarray.put(wifi2);

    holder.put("homeMobileCountryCode", mcc);
    holder.put("homeMobileNetworkCode", mnc);
    holder.put("radioType", "gsm");
    holder.put("carrier", "T-Mobile");
    holder.put("cellTowers", cellarray);
    holder.put("wifiAccessPoints", wifiarray);


} catch (JSONException e) {  
    e.printStackTrace();  
}
DefaultHttpClient client = new DefaultHttpClient();
HttpPost httpPost = new HttpPost("https://www.googleapis.com/geolocation/v1/geolocate?key="+API_key);
StringEntity stringEntity = null;  

try {  
    stringEntity = new StringEntity(holder.toString());  
    stringEntity.setContentType("application/json");

    Log.v("zf",stringEntity.getContentType().toString());

} catch (UnsupportedEncodingException e) {  
    e.printStackTrace();  
}

httpPost.setEntity(stringEntity);  
HttpResponse httpResponse = null;  
try {
    httpResponse = client.execute(httpPost);  
} catch (ClientProtocolException e) {  
    e.printStackTrace();  
} catch (IOException e) {  
    e.printStackTrace();  
} 

最佳答案

可能的原因 #1:将传感器值添加到您的 url,它不是可选的!

可能的原因 #2:您是否在 API 控制台中启用了地理定位服务?

可能的原因 #3:您是否在 API 控制台中设置了结算信息?

关于android - 谷歌地图地理定位 api : access not configured,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/14474005/

相关文章:

android - 当我们在室内使用安卓手机时,如何快速获取经纬度或gps数据?

android - NoSuchFieldError : No static field MapAttrs of type when Using MapFragment with Play Services 6. 5

安卓搜索管理器 : How to set minimum number of characters to enable the Search

android - 从Android Studio中的素材资源文件夹加载html页面时出错

Android X509TrustManager#checkServerTrusted 在 API > 23 上抛出 CertificateException

android - Gradle SwingBuilder: “Toolkit not found: apple.awt.CToolkit”错误

javascript - 返回我之前指定的 Google map 位置列表

flutter - 如果语句在我的 Dart Flutter 代码中被注册为变量?我该如何改变?

android - 查看哪些 map 图 block 在 Google Maps for Android v2 中可见

java - 请求位置的运行时权限时