【发布时间】:2014-05-18 14:17:39
【问题描述】:
我使用谷歌地图在两个位置之间获得了一条折线,当我想通过使用 Json 解析使用此 URL 来获取这两个位置之间的路线和方向时 https://maps.googleapis.com/maps/api/directions/json?origin=fromlocation&destination=destinationlocation&sensor=false&key=********API KEY********* 它正在将json解析为 { "error_message" : "此 IP、站点或移动应用程序无权使用此 API 密钥。", “路线”:[], “状态”:“REQUEST_DENIED” } 我已经使用 keytool 以及包名和指纹密钥获得了授权的 APIKEY
这是我所做的代码,提前感谢我的英语......
私有类 GetContacts 扩展 AsyncTask {
@Override
protected void onPreExecute() {
super.onPreExecute();
// Showing progress dialog
pDialog = new ProgressDialog(DirectionActivity2.this);
pDialog.setMessage("Please wait...");
pDialog.setCancelable(true);
pDialog.show();
}
@Override
protected Void doInBackground(Void... arg0) {
String URL="https://maps.googleapis.com/maps/api/directions/json?origin=start&destination=end&sensor=false&key=****API KEY*****";
ServiceHandler sh = new ServiceHandler();
// Making a request to url and getting response
String jsonStr = sh.makeServiceCall(URL, ServiceHandler.GET);
Log.d("Response: ", "> " + jsonStr);
return null;
}
@Override
protected void onPostExecute(Void result) {
super.onPostExecute(result);
// Dismiss the progress dialog
if (pDialog.isShowing())
pDialog.dismiss();
}
}
【问题讨论】:
标签: android json google-maps