GPS를 사용하지 않고 내 Blackberry 장치의 위치를 가져오고 싶습니다. 그래서, 결과를 Opencellid를 사용하고 있습니다. 그러나 그것은 나에게 틀린 위치 결과를주고있다. 누구나 정확한 절차와 내가 잘못하고있는 것을 명확히 할 수 있습니까?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());
}
}
}
below- 주어진? – Signare
예, GPS를 사용하지 않습니다. –
오류 또는 예외는 무엇입니까? 또한 셀 사이트 모드에서 기본 제공되는 LocationProvider를 사용하여 위치를 검색하는 방법을 확인하는 것이 좋습니다. http://docs.blackberry.com/en/developers/deliverables/34488/GPS_overview_1679738_11.jsp –