zoukankan      html  css  js  c++  java
  • Android中获取基于基站的经纬度信息

    1. <SPAN style="FONT-FAMILY: Tahoma, Helvetica, SimSun, sans-serif, Hei; WHITE-SPACE: normal"></SPAN> 
    
    

    目前获取经纬度一共有两种方法:

    一是通过谷歌的地图API来获取经纬度,一般获取的精确度比较的大,详细请参考文章:

    http://www.shouyanwang.org/thread-32-1-1.html

    还剩下的一种就是借助移动的基站定位来获取经纬度:

    移动基站的定位必须借助存储卡,目前已经测试的,中国电信和中国移动的卡都支持,联通的还没有测试,那么如何获取借助基站获取经纬度呢?

    借助TelephonyManager和GsmCellLocation就可以实现了,非常的简单,获取的值为整型的值,因此是没有通过谷歌地图API的精确的。

    1. privateint cellId = 0
    2. privateint lac = 0
    3.  
    4. privatevoid getCellLac(){ 
    5. TelephonyManager tm = (TelephonyManager)getSystemService(TELEPHONY_SERVICE); 
    6. String OperatorName = tm.getNetworkOperatorName(); 
    7. if(OperatorName.equals("中国联通") || OperatorName.equals("中国移动")||OperatorName.equals("中国电信")){ 
    8. GsmCellLocation location = (GsmCellLocation)tm.getCellLocation(); 
    9. cellId = location.getCid(); 
    10. lac = location.getLac(); 
    private int cellId = 0;
    private int lac = 0;
    
    private void getCellLac(){
    TelephonyManager tm = (TelephonyManager)getSystemService(TELEPHONY_SERVICE);
    String OperatorName = tm.getNetworkOperatorName();
    if(OperatorName.equals("中国联通") || OperatorName.equals("中国移动")||OperatorName.equals("中国电信")){
    GsmCellLocation location = (GsmCellLocation)tm.getCellLocation();
    cellId = location.getCid();
    lac = location.getLac();
    }
    }
  • 相关阅读:
    RelativeLayout布局属性
    调整CodeIgniter错误报告级别
    php 报错 Cannot modify header information
    ScrollView中嵌套ListView
    机器学习索引贴(未分类)
    进程与线程
    并行程序
    缓存命中率
    启发式算法(Heuristic Algorithm)
    详解 LSTM
  • 原文地址:https://www.cnblogs.com/LiaoHao/p/3267925.html
Copyright © 2011-2022 走看看