zag*_*fox 6 android geolocation google-maps-android-api-2
我想在Android上使用谷歌地理定位API.我确信我有Android的有效apikey,我启用了计费功能.但是,服务器返回
doman:usageLimits共振:访问未配置的代码: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();
}
Run Code Online (Sandbox Code Playgroud)
可能的原因#1:将传感器值添加到您的网址中,它不是可选的!
可能的原因#2:您是否在 API 控制台中启用了地理位置服务?
可能的原因#3:您是否在 API 控制台中设置了账单信息?
| 归档时间: |
|
| 查看次数: |
1520 次 |
| 最近记录: |