我在得到CID和LAC后
用下面的方式,获取经纬度,发现原来可以获取的,今天获取不了了~~~~~过期了么??
http://www.anttna.com/cell2gps/cell2gps.php?以下是摘自网络的部分代码~~~~
String strCid = "http://www.anttna.com/cell2gps/cell2gps.php?lac="
+ lac + "&cellid=" + cid;
String strRS = GetCIDName(strCid);public String GetCIDName(String url)
{
URL internetUrl = null;
String strRS = new String("无效结果");
int length = -1;
try {
internetUrl = new URL(url);
}
catch (MalformedURLException e)
{
e.printStackTrace();
ShowDebugInfo("网络连接异常,地址错误");
return strRS;
}
HttpURLConnection conn = null;
try
{
conn = (HttpURLConnection)internetUrl.openConnection();
conn.setDoInput(true);
conn.setConnectTimeout(2000);
byte[] data = new byte[4096];
for (int i = 0; i < 4096; i++) {
data[i] = 0;
}
conn.connect();
InputStream is = conn.getInputStream();
length = is.read(data);
//String str = new String(data, 0, length);
//String strEnc = EncodingUtils.getString(data, "UNICODE");
//String strEnc = new String(data, "GBK");
strRS = new String(data, "GBK");
//myTextView.setText(strEnc);
//ShowDebugInfo("网络获取成功");
}
catch (IOException e)
{
e.printStackTrace();
ShowDebugInfo(e.getMessage());
//myTextView.setText(e.getMessage());
}
finally
{
if (conn != null)
{
conn.disconnect();
conn = null;
internetUrl = null;
}
}
是网址过期?还是服务器忙啊..
用下面的方式,获取经纬度,发现原来可以获取的,今天获取不了了~~~~~过期了么??
http://www.anttna.com/cell2gps/cell2gps.php?以下是摘自网络的部分代码~~~~
String strCid = "http://www.anttna.com/cell2gps/cell2gps.php?lac="
+ lac + "&cellid=" + cid;
String strRS = GetCIDName(strCid);public String GetCIDName(String url)
{
URL internetUrl = null;
String strRS = new String("无效结果");
int length = -1;
try {
internetUrl = new URL(url);
}
catch (MalformedURLException e)
{
e.printStackTrace();
ShowDebugInfo("网络连接异常,地址错误");
return strRS;
}
HttpURLConnection conn = null;
try
{
conn = (HttpURLConnection)internetUrl.openConnection();
conn.setDoInput(true);
conn.setConnectTimeout(2000);
byte[] data = new byte[4096];
for (int i = 0; i < 4096; i++) {
data[i] = 0;
}
conn.connect();
InputStream is = conn.getInputStream();
length = is.read(data);
//String str = new String(data, 0, length);
//String strEnc = EncodingUtils.getString(data, "UNICODE");
//String strEnc = new String(data, "GBK");
strRS = new String(data, "GBK");
//myTextView.setText(strEnc);
//ShowDebugInfo("网络获取成功");
}
catch (IOException e)
{
e.printStackTrace();
ShowDebugInfo(e.getMessage());
//myTextView.setText(e.getMessage());
}
finally
{
if (conn != null)
{
conn.disconnect();
conn = null;
internetUrl = null;
}
}
是网址过期?还是服务器忙啊..
or (int i = 0; i < 4096; i++) {
data[i] = 0;
}
conn.connect();
InputStream is = conn.getInputStream();
length = is.read(data);I/XXW ( 1362): 9999999999999999999999999999999------------------------!!!!!!!!!!
I/XXW ( 1362): 4444444444444444444------------------------!!!!!!!!!!
W/System.err( 1362): java.net.UnknownHostException: www.anttna.com
W/System.err( 1362): at java.net.InetAddress.lookupHostByName(InetAddress.java:506)
W/System.err( 1362): at java.net.InetAddress.getAllByNameImpl(InetAddress.java:294)
W/System.err( 1362): at java.net.InetAddress.getAllByName(InetAddress.java:256)
W/System.err( 1362): at org.apache.harmony.luni.internal.net.www.protocol.http.HttpConnection.<init>(HttpConnection.java:68)
W/System.err( 1362): at org.apache.harmony.luni.internal.net.www.protocol.http.HttpConnection.<init>(HttpConnection.java:48)
W/System.err( 1362): at org.apache.harmony.luni.internal.net.www.protocol.http.HttpConnection$Address.connect(HttpConnection.java:298)
W/System.err( 1362): at org.apache.harmony.luni.internal.net.www.protocol.http.HttpConnectionPool.get(HttpConnectionPool.java:89)
W/System.err( 1362): at org.apache.harmony.luni.internal.net.www.protocol.http.HttpURLConnectionImpl.getHttpConnection(HttpURLConnectionImpl.java:285)
W/System.err( 1362): at org.apache.harmony.luni.internal.net.www.protocol.http.HttpURLConnectionImpl.makeConnection(HttpURLConnectionImpl.java:267)
是这个POST的地址太老了?
谁推荐一种由CID和LAC栏获取经纬度的方式啊.............谢谢!!!!