我希望使用GsmCellLocation
来获取经度和纬度。我得到了CID,LAC,MCC和MNC。但是当试图通过使用
urlString = "http://www.google.com/glm/mmap"
它给我一个openHttpConnection
错误。我尝试过很多教程,但结果相同。这是我的另一个教程中获取long / lat的代码。
private Boolean RqsLocation(int cid, int lac) {
Boolean result = false;
String urlmmap = "http://www.google.com/glm/mmap";
try {
URL url = new URL(urlmmap);
URLConnection conn = url.openConnection();
HttpURLConnection httpConn = (HttpURLConnection) conn;
httpConn.setRequestMethod("POST");
httpConn.setDoOutput(true);
httpConn.setDoInput(true);
httpConn.connect();
OutputStream outputStream = httpConn.getOutputStream();
WriteData(outputStream, cid, lac);
InputStream inputStream = httpConn.getInputStream();
DataInputStream dataInputStream = new DataInputStream(inputStream);
dataInputStream.readShort();
dataInputStream.readByte();
int code = dataInputStream.readInt();
if (code == 0) {
myLatitude = dataInputStream.readInt();
System.out.println("The lattitude value is " + myLatitude);
myLongitude = dataInputStream.readInt();
System.out.println("The lattitude value is " + myLongitude);
result = true;
}
} catch (IOException e) {
e.printStackTrace();
}
return result;
}
我已在清单文件中授予权限。
这个问题之前已经提出过,但我没有得到任何答案。
答案 0 :(得分:1)
如果没有GPS,您还可以使用Network_Provider获取纬度和经度。
.shrink a {
line-height: <whatever>;
}