GPSを使用せずにBlackberryデバイスの位置を取得したい。そのため、結果としてOpencellidを使用しています。しかし、それは私に間違った場所の結果を与えています。正確な手順と私が間違っている可能性があることを誰かが明確にできますか?
私のコード:
public final static String getQueryString(){
cellID = Integer.toString(GPRSInfo.getCellInfo().getCellId());
// Retrieves the Location Area Code.
lac = Integer.toString(GPRSInfo.getCellInfo().getLAC());
// Retrieves the mobile country code.
mcc = Integer.toHexString(RadioInfo.getMCC(RadioInfo.getCurrentNetworkIndex()));
// Retrieves the Location network Code.
mnc = Integer.toHexString(RadioInfo.getMNC(RadioInfo.getCurrentNetworkIndex()));
queryStr="http://www.opencellid.org/cell/get?
key="+myapikey+"&mcc="+mcc+"&mnc="+mnc+"&cellid="+cellID+"&lac="+lac+"&fmt=txt";
return queryStr;
}
public void httpGetRequest(){
HttpConnection conn = null;
InputStream in = null; StringBuffer buff = new StringBuffer(); String result = "";
try {
conn=(HttpConnection) Connector.open(getQueryString()+getString(),Connector.READ);
conn.setRequestMethod(HttpConnection.GET); conn.setRequestProperty("User-Agent", "Profile/MIDP-1.0 Confirguration/CLDC-1.0");
conn.setRequestProperty("Content-Type", "plain/text");
in = conn.openInputStream();
int car;
while( (car=in.read())!= -1){
buff.append((char)car);
}
in.close();
conn.close();
result=buff.toString();
//get latitude and longitude
if(result.startsWith("err")){
System.out.println("Cell not found!");
}else{
int pos=result.indexOf(',');
String lat=result.substring(0,pos);
int pos2=result.indexOf(',',pos+1);
String lon=result.substring(pos+1,pos2);
System.out.println(lat+" "+lon);
getLocationFromGoogleMaps(lat,lon);
}
} catch (Exception ex) {
System.out.println("====Exception: "+ex.getMessage());
} finally {
try {
if (in != null) {
in.close();
}
conn.close();
} catch (IOException e) {
System.out.println("====Exception: "+e.getMessage());
}
}
}