【问题标题】:Monitoring GPS receiver/adapter status监控 GPS 接收器/适配器状态
【发布时间】:2011-05-26 20:21:10
【问题描述】:

我只需要监控 GPS 接收器或适配器的状态,如果用户手动禁用 gps,我的应用程序将无法工作...

尝试使用此链接中的信息,但没有帮助 - How can I monitor the status of the GPS adapter using Android SDK?

有什么想法吗?

【问题讨论】:

    标签: java android gps


    【解决方案1】:

    要检查 GPS 的可用性,您可以使用以下代码

    LocationManager locationManager = (LocationManager)getSystemService(Context.LOCATION_SERVICE);
    
        if(!locationManager.isProviderEnabled(LocationManager.GPS_PROVIDER)) {
            //gps off. User turned the GPS off manually. 
        }
    

    【讨论】:

      【解决方案2】:
         boolean gpSstate = locationManager.isProviderEnabled( LocationManager.GPS_PROVIDER);
          boolean networkState =locationManager.isProviderEnabled(LocationManager.NETWORK_PROVIDER);
      if(!gpsState && !networkState) {// no GPS Service }
      

      【讨论】:

        猜你喜欢
        • 1970-01-01
        • 1970-01-01
        • 1970-01-01
        • 1970-01-01
        • 1970-01-01
        • 1970-01-01
        • 2011-01-02
        • 1970-01-01
        • 1970-01-01
        相关资源
        最近更新 更多