久久久久久久av_日韩在线中文_看一级毛片视频_日本精品二区_成人深夜福利视频_武道仙尊动漫在线观看

    • <bdo id='m53o9'></bdo><ul id='m53o9'></ul>
  • <legend id='m53o9'><style id='m53o9'><dir id='m53o9'><q id='m53o9'></q></dir></style></legend>

    <small id='m53o9'></small><noframes id='m53o9'>

    <tfoot id='m53o9'></tfoot>

  • <i id='m53o9'><tr id='m53o9'><dt id='m53o9'><q id='m53o9'><span id='m53o9'><b id='m53o9'><form id='m53o9'><ins id='m53o9'></ins><ul id='m53o9'></ul><sub id='m53o9'></sub></form><legend id='m53o9'></legend><bdo id='m53o9'><pre id='m53o9'><center id='m53o9'></center></pre></bdo></b><th id='m53o9'></th></span></q></dt></tr></i><div class="qwawimqqmiuu" id='m53o9'><tfoot id='m53o9'></tfoot><dl id='m53o9'><fieldset id='m53o9'></fieldset></dl></div>

      1. 根據(jù)可用性在 gps 和網(wǎng)絡(luò)提供商之間切換

        Switching between gps and network provider according to the availability(根據(jù)可用性在 gps 和網(wǎng)絡(luò)提供商之間切換)
      2. <tfoot id='tKGsA'></tfoot>

                <tbody id='tKGsA'></tbody>
                <bdo id='tKGsA'></bdo><ul id='tKGsA'></ul>
                <legend id='tKGsA'><style id='tKGsA'><dir id='tKGsA'><q id='tKGsA'></q></dir></style></legend>

                <i id='tKGsA'><tr id='tKGsA'><dt id='tKGsA'><q id='tKGsA'><span id='tKGsA'><b id='tKGsA'><form id='tKGsA'><ins id='tKGsA'></ins><ul id='tKGsA'></ul><sub id='tKGsA'></sub></form><legend id='tKGsA'></legend><bdo id='tKGsA'><pre id='tKGsA'><center id='tKGsA'></center></pre></bdo></b><th id='tKGsA'></th></span></q></dt></tr></i><div class="qwawimqqmiuu" id='tKGsA'><tfoot id='tKGsA'></tfoot><dl id='tKGsA'><fieldset id='tKGsA'></fieldset></dl></div>
                • <small id='tKGsA'></small><noframes id='tKGsA'>

                  本文介紹了根據(jù)可用性在 gps 和網(wǎng)絡(luò)提供商之間切換的處理方法,對(duì)大家解決問(wèn)題具有一定的參考價(jià)值,需要的朋友們下面隨著小編來(lái)一起學(xué)習(xí)吧!

                  問(wèn)題描述

                  public void onCreate() {
                   locationListener = new GeoUpdateHandler();
                   locationManager = (LocationManager) getSystemService(Context.LOCATION_SERVICE);
                  
                  try {
                     gps_enabled = locationManager.isProviderEnabled(LocationManager.GPS_PROVIDER);
                     network_enabled = locationManager.isProviderEnabled(LocationManager.NETWORK_PROVIDER);
                  } catch (Exception ex) { 
                  }
                  
                  if(gps_enabled) {
                         locationManager.requestLocationUpdates(LocationManager.GPS_PROVIDER, TIME_DURATION, 100, locationListener);
                  } else if(network_enabled) { // Checking for GSM
                     locationManager.requestLocationUpdates(LocationManager.NETWORK_PROVIDER, TIME_DURATION, DISTANCE, locationListener);
                  }   
                  }   
                  public class GeoUpdateHandler implements LocationListener {
                  private void getPresentLocation(Location location) {
                      ... 
                              //Fetch the locations
                              ...
                  }
                  
                  @Override
                  public void onProviderDisabled(String provider) { }
                  
                  @Override
                  public void onProviderEnabled(String provider) { }
                  
                  @Override
                  public void onStatusChanged(String provider, int status, Bundle extras) { }
                  
                  @Override
                  public void onLocationChanged(Location location) {
                      getPresentLocation(location);
                  }
                  }
                  

                  這是我的代碼片段,我的問(wèn)題是,一旦在 GPS 開(kāi)啟的情況下安裝了應(yīng)用程序,那么一旦我們關(guān)閉 GPS,它就不會(huì)切換到 GSM 來(lái)獲取位置,反之亦然.

                  this is my code snippet and my issue is that once the application is installed with GPS Switched ON, then it is not switching to GSM to fetch location once we OFF GPS, and vice versa.

                  所以請(qǐng)告訴我一種根據(jù)位置提供商的可用性在 GPS 和 GSM 之間有效切換的方法.

                  So please tell me a way to switch efficiently between GPS and GSM according to the availability of the location provider.

                  注意:我的應(yīng)用是一項(xiàng)服務(wù).

                  NOTE: My app is a service.

                  謝謝.

                  我有一個(gè)廣播接收器,這就是為什么我假設(shè)一旦 GPS 開(kāi)/關(guān)發(fā)生就會(huì)調(diào)用 onCreate().

                  I got a BroadcastReceiver, thats why i assume the onCreate() will be invoked once the GPS ON/OFF happen.

                  我還嘗試在 onLocationChanged(Location location) 中檢查提供程序的可用性.但它沒(méi)有幫助.

                  I also tried checking the provider availability in onLocationChanged(Location location). But it didnt helped.

                  我修改了我的 onProviderDisabled &onProviderEnabled 像這樣,請(qǐng)告訴我在這里做錯(cuò)了什么..

                  I modified my onProviderDisabled & onProviderEnabled like this, Please tell what i am doing wrong here..

                      public void onProviderDisabled(String provider) {
                          locationManager.removeUpdates(locationListener);
                          if (provider.toLowerCase().equals(LocationManager.GPS_PROVIDER)) {
                              locationManager.requestLocationUpdates(LocationManager.NETWORK_PROVIDER, TIME_DURATION, 1, locationListener);               
                          } else {
                              locationManager.requestLocationUpdates(LocationManager.GPS_PROVIDER, TIME_DURATION, 1, locationListener);
                          }   
                      }
                  
                      @Override
                      public void onProviderEnabled(String provider) {
                          locationManager.removeUpdates(locationListener);
                          if (provider.toLowerCase().equals(LocationManager.GPS_PROVIDER)) {
                              locationManager.requestLocationUpdates(LocationManager.GPS_PROVIDER, TIME_DURATION, 1, locationListener);
                          } else {
                              locationManager.requestLocationUpdates(LocationManager.NETWORK_PROVIDER, TIME_DURATION, 1, locationListener);
                          }
                  
                      }
                  

                  推薦答案

                  得到了解決方案:

                   public void onProviderDisabled(String provider) {
                     locationManager = (LocationManager) getSystemService(Context.LOCATION_SERVICE);
                     if (locationManager.isProviderEnabled(LocationManager.GPS_PROVIDER)) {
                      locationManager.requestLocationUpdates(LocationManager.GPS_PROVIDER, 0, 0,  locationListener);
                     } else {
                        locationManager.requestLocationUpdates(LocationManager.NETWORK_PROVIDER, 0, 0, locationListener);
                     } 
                  }
                  
                  @Override
                  public void onProviderEnabled(String provider) {
                    locationManager = (LocationManager) getSystemService(Context.LOCATION_SERVICE);   
                    if (locationManager.isProviderEnabled(LocationManager.GPS_PROVIDER)) {
                      locationManager.requestLocationUpdates(LocationManager.GPS_PROVIDER, 0, 0, locationListener);
                    } else {
                      locationManager.requestLocationUpdates(LocationManager.NETWORK_PROVIDER, 0, 0, locationListener);
                    }
                  }
                  

                  我錯(cuò)過(guò)的是locationManager = (LocationManager) getSystemService(Context.LOCATION_SERVICE);在 onProviderEnabled() 和 onProviderDisabled() 中.

                  what i missed is locationManager = (LocationManager) getSystemService(Context.LOCATION_SERVICE); in onProviderEnabled() and onProviderDisabled().

                  謝謝

                  這篇關(guān)于根據(jù)可用性在 gps 和網(wǎng)絡(luò)提供商之間切換的文章就介紹到這了,希望我們推薦的答案對(duì)大家有所幫助,也希望大家多多支持html5模板網(wǎng)!

                  【網(wǎng)站聲明】本站部分內(nèi)容來(lái)源于互聯(lián)網(wǎng),旨在幫助大家更快的解決問(wèn)題,如果有圖片或者內(nèi)容侵犯了您的權(quán)益,請(qǐng)聯(lián)系我們刪除處理,感謝您的支持!

                  相關(guān)文檔推薦

                  Help calculating X and Y from Latitude and Longitude in iPhone(幫助從 iPhone 中的緯度和經(jīng)度計(jì)算 X 和 Y)
                  Get user#39;s current location using GPS(使用 GPS 獲取用戶(hù)的當(dāng)前位置)
                  IllegalArgumentException thrown by requestLocationUpdate()(requestLocationUpdate() 拋出的 IllegalArgumentException)
                  How reliable is LocationManager#39;s getLastKnownLocation and how often is it updated?(LocationManager 的 getLastKnownLocation 有多可靠,多久更新一次?)
                  CLLocation returning negative speed(CLLocation 返回負(fù)速度)
                  How to detect Location Provider ? GPS or Network Provider(如何檢測(cè)位置提供者?GPS 或網(wǎng)絡(luò)提供商)

                      <tbody id='cCen8'></tbody>

                    <small id='cCen8'></small><noframes id='cCen8'>

                    <tfoot id='cCen8'></tfoot>
                    <legend id='cCen8'><style id='cCen8'><dir id='cCen8'><q id='cCen8'></q></dir></style></legend>

                      • <bdo id='cCen8'></bdo><ul id='cCen8'></ul>
                        • <i id='cCen8'><tr id='cCen8'><dt id='cCen8'><q id='cCen8'><span id='cCen8'><b id='cCen8'><form id='cCen8'><ins id='cCen8'></ins><ul id='cCen8'></ul><sub id='cCen8'></sub></form><legend id='cCen8'></legend><bdo id='cCen8'><pre id='cCen8'><center id='cCen8'></center></pre></bdo></b><th id='cCen8'></th></span></q></dt></tr></i><div class="qwawimqqmiuu" id='cCen8'><tfoot id='cCen8'></tfoot><dl id='cCen8'><fieldset id='cCen8'></fieldset></dl></div>

                            主站蜘蛛池模板: 日韩在线播放第一页 | 久久精品一区 | 亚洲第一网站 | 美女毛片免费看 | 国产精品久久久久久婷婷天堂 | 中文在线a在线 | 涩色视频在线观看 | 日韩av在线一区 | 一级a性色生活片久久毛片波多野 | 久久久无码精品亚洲日韩按摩 | 精品福利一区 | 国产午夜精品久久久 | 中文字幕乱码一区二区三区 | 999久久久国产精品 欧美成人h版在线观看 | 欧美日韩亚洲国产 | 日本视频中文字幕 | 国产精品视频在线观看 | 精品国产乱码久久久久久闺蜜 | 国产福利91精品 | 日韩三级电影在线看 | 国产精品自拍啪啪 | 精品国产乱码久久久久久蜜柚 | 亚洲综合二区 | 精品一二三 | 日韩精品一区二区三区在线播放 | 国产精品国产三级国产aⅴ中文 | 国产xxxx搡xxxxx搡麻豆 | 久久伊人免费视频 | 欧美一级久久 | 亚洲3级| 一区二区三区不卡视频 | 9999视频 | 色综合色综合 | 亚洲成人在线免费 | 亚洲资源在线 | 亚洲国产一区二区三区, | 精久久久 | 免费一级黄色录像 | 国产乱码精品一区二区三区五月婷 | 亚洲国产成人精品久久久国产成人一区 | 国产成人a亚洲精品 |