You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Dear all,
I post cell information (CID,LAC,MCC,MNC...) to https://www.googleapis.com/geolocation/v1/geolocate?key=my_key,but it always return error 400,can you help me ? Thanks~
1)return error information as follows:
{
"error": {
"errors": [
{
"domain": "global",
"reason": "parseError",
"message": "Parse Error"
}
],
"code": 400,
"message": "Parse Error"
}
}
2)I implement as follows:
public class SCell{
public int MCC;
public int MNC;
public int LAC;
public int CID;
}
private SItude getItude(SCell cell) throws Exception {
SItude itude = new SItude();
/** Using HttpClient of android by default*/
HttpClient client = new DefaultHttpClient();
/** using post'method */
HttpPost post = new HttpPost("https://www.googleapis.com/geolocation/v1/geolocate?key=XXXXXXXXXXXXXXXXXX");
try {
/** POST JSON data structure */
JSONObject holder = new JSONObject();
holder.put("homeMobileCountryCode", cell.MCC);
holder.put("homeMobileNetworkCode", cell.MNC);
holder.put("radioType", "gsm");
holder.put("carrier", "cmcc");
JSONObject tower = new JSONObject();
tower.put("cellId", cell.CID);
tower.put("locationAreaCode", cell.LAC);
tower.put("mobileCountryCode", cell.MCC);
tower.put("mobileNetworkCode", cell.MNC);
tower.put("age", 0);
tower.put("signalStrength", -60);
tower.put("timingAdvance", 15);
JSONArray towerarray = new JSONArray();
towerarray.put(tower);
holder.put("cellTowers", towerarray);
StringEntity query = new StringEntity(holder.toString());
post.setEntity(query);
/** send out JSON data,and return data */
HttpResponse response = client.execute(post);
HttpEntity entity = response.getEntity();
BufferedReader buffReader = new BufferedReader(new InputStreamReader(entity.getContent()));
StringBuffer strBuff = new StringBuffer();
String result = null;
while ((result = buffReader.readLine()) != null) {
strBuff.append(result);
}
/** parse JSON data to get longitude and latitude */
JSONObject json = new JSONObject(strBuff.toString());
JSONObject subjosn = new JSONObject(json.getString("location"));
itude.latitude = subjosn.getString("latitude");
itude.longitude = subjosn.getString("longitude");
Log.i("Itude", itude.latitude + itude.longitude);
} catch (Exception e) {
Log.e(e.getMessage(), e.toString());
throw new Exception("error info :"+e.getMessage());
} finally{
post.abort();
client = null;
}
return itude;
}
Original issue reported on code.google.com by [email protected] on 8 Jun 2013 at 9:24
The text was updated successfully, but these errors were encountered:
Original issue reported on code.google.com by
[email protected]
on 8 Jun 2013 at 9:24The text was updated successfully, but these errors were encountered: