/**
* Parses data from PhoneStateListener.LISTEN_CELL_LOCATION.onCellLocationChanged
* http://developer.android.com/reference/android/telephony/cdma/CdmaCellLocation.html
* @param location CdmaCellLocation
* @return JSON
*/
public static String cdmaCellLocationJSON(CdmaCellLocation location){
final Calendar calendar = Calendar.getInstance();
final JSONObject json = new JSONObject();
if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.JELLY_BEAN_MR2 && location != null) {
try {
json.put("provider", CELLLOCATION_PROVIDER);
json.put("type", CDMA);
json.put("timestamp", calendar.getTimeInMillis());
json.put("baseStationId", location.getBaseStationId()); // -1 if unknown
json.put("networkId", location.getNetworkId()); // -1 if unknown
json.put("systemId", location.getSystemId()); // -1 if unknown
json.put("baseStationLatitude", CdmaCellLocation.convertQuartSecToDecDegrees(location.getBaseStationLatitude()));
json.put("baseStationLongitude", CdmaCellLocation.convertQuartSecToDecDegrees(location.getBaseStationLongitude()));
}
catch(JSONException exc) {
logJSONException(exc);
}
}
return json.toString();
}
JSONHelper.java 文件源码
java
阅读 33
收藏 0
点赞 0
评论 0
项目:localcloud_fe
作者:
评论列表
文章目录