10-26-2012 03:20 AM - edited 10-26-2012 03:22 AM
Below is my code:
public final String getQueryString(){
// Retrieves the cell id
String cellID = Integer.toString(GPRSInfo.getCellInfo().getCellId( ));
// Retrieves the Location Area Code.
String lac = Integer.toString(GPRSInfo.getCellInfo().getLAC());
// Retrieves the mobile country code.
String mcc = Integer.toHexString(RadioInfo.getMCC(RadioInfo
.getCurrentNetworkIndex()));
// Retrieves the Location network Code.
String mnc = Integer.toHexString(RadioInfo.getMNC(RadioInfo
.getCurrentNetworkIndex()));
String queryStr="http://www.opencellid.org/cell/get?key="+myapikey+"&mcc="+mcc+"&mnc="+mnc+"&cellid="+cell ID+"&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());
in = conn.openInputStream();
buff.append(IOUtilities.streamToBytes(in));
result = buff.toString();
System.out.println(result);
} 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());
}
}
}
But the line highlighted above gives Exception:
Local connection timed out after ~12000
Please help.
Solved! Go to Solution.
10-26-2012 06:18 AM
Anybody who can answer my query?.. Stuck on it since a long time..
Thanks in advance..
10-27-2012 07:26 PM
I don't think the problem here is related to OPen Cellid. I think the problem is the http get code.
I would look at the sample httpdemo code to see what a GET should look like.
And make sure you understand the connection method you are using. The following network video will help::
http://supportforums.blackberry.com/t5/Java-Develo
This will help too:
Now if you don't want to code connection strings yourself, look at ConnectionFactory.
But the most important thing is to review httpDemo and test this in the Simulator (with BES MDS Simulator running). Try changing the URL it requests to match the URL your code creates and see what happens too.