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

<legend id='kpKF4'><style id='kpKF4'><dir id='kpKF4'><q id='kpKF4'></q></dir></style></legend>

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

      1. <small id='kpKF4'></small><noframes id='kpKF4'>

        OnLocationChanged 回調(diào)永遠(yuǎn)不會(huì)被調(diào)用

        OnLocationChanged callback is never called(OnLocationChanged 回調(diào)永遠(yuǎn)不會(huì)被調(diào)用)

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

        <legend id='Qto6o'><style id='Qto6o'><dir id='Qto6o'><q id='Qto6o'></q></dir></style></legend>

          <bdo id='Qto6o'></bdo><ul id='Qto6o'></ul>
            <tbody id='Qto6o'></tbody>

            • <tfoot id='Qto6o'></tfoot>
                1. <small id='Qto6o'></small><noframes id='Qto6o'>

                2. 本文介紹了OnLocationChanged 回調(diào)永遠(yuǎn)不會(huì)被調(diào)用的處理方法,對(duì)大家解決問題具有一定的參考價(jià)值,需要的朋友們下面隨著小編來一起學(xué)習(xí)吧!

                  問題描述

                  我正在嘗試使用 LocationManager 獲取用戶的當(dāng)前位置.我做了很多研究,似乎找不到任何有同樣問題的人.OnLocationChanged 回調(diào)似乎永遠(yuǎn)不會(huì)被調(diào)用.下面是我的各種代碼和logcat.

                  I am trying to get the users current location using the LocationManager. I have done a lot of research and can't seem to find anyone with the same problem. The OnLocationChanged callback never seems to be called. Below is my various code and the logcat.

                  protected LocationListener locationListener;
                  protected LocationManager locationManager;
                  protected Context context;
                  

                  我的 OnCreate() 方法

                  @Override
                  public void onCreate(Bundle savedInstanceState) {
                      super.onCreate(savedInstanceState);
                      Log.v(TAG, "IN ON CREATE");
                  
                      this.context = getActivity();
                  
                      registerLocationUpdates();
                  }
                  

                  我的 registerLocationUpdates 方法

                  void registerLocationUpdates() {
                      Criteria criteria = new Criteria();
                      criteria.setAccuracy(Criteria.ACCURACY_LOW);
                      criteria.setPowerRequirement(Criteria.POWER_LOW);
                      criteria.setAltitudeRequired(false);
                      criteria.setBearingRequired(false);
                  
                      locationManager = (LocationManager)getActivity().getSystemService(LOCATION_SERVICE);
                  
                      provider = locationManager.getBestProvider(criteria, true);
                  
                      // Cant get a hold of provider
                      if (provider == null) {
                          Log.v(TAG, "Provider is null");
                          showNoProvider();
                          return;
                      } else {
                          Log.v(TAG, "Provider: " + provider);
                      }
                  
                      locationListener = new MyLocationListener();
                  
                      locationManager.requestLocationUpdates(provider, 1L, 1f, locationListener);
                  
                      // connect to the GPS location service
                      Location oldLocation = locationManager.getLastKnownLocation(provider);
                  
                      if (oldLocation != null)  {
                          Log.v(TAG, "Got Old location");
                          latitude = Double.toString(oldLocation.getLatitude());
                          longitude = Double.toString(oldLocation.getLongitude());
                          waitingForLocationUpdate = false;
                          getNearbyStores();
                      } else {
                          Log.v(TAG, "NO Last Location found");
                      }
                  }
                  

                  我的LocationListener

                  private class MyLocationListener implements LocationListener {
                  
                      public void onLocationChanged(Location location) {
                          latitude = Double.toString(location.getLatitude());
                          longitude = Double.toString(location.getLongitude());
                  
                          Log.v(TAG, "IN ON LOCATION CHANGE");
                  
                          if (waitingForLocationUpdate) {
                              getNearbyStores();
                              waitingForLocationUpdate = false;
                          }
                  
                          locationManager.removeUpdates(this);
                      }
                  
                      public void onStatusChanged(String s, int i, Bundle bundle) {
                          Log.v(TAG, "Status changed: " + s);
                      }
                  
                      public void onProviderEnabled(String s) {
                          Log.e(TAG, "PROVIDER DISABLED: " + s);
                      }
                  
                      public void onProviderDisabled(String s) {
                          Log.e(TAG, "PROVIDER DISABLED: " + s);
                      }
                  }
                  

                  我在 AndroidManifest 中的權(quán)限

                  My permissions in the AndroidManifest

                  <uses-permission android:name="android.permission.INTERNET" />
                  <uses-permission android:name="android.permission.ACCESS_NETWORK_STATE" />
                  <uses-permission android:name="android.permission.ACCESS_FINE_LOCATION" />
                  

                  最后是我運(yùn)行我的應(yīng)用程序后的 logcat

                  And finally the logcat after I run my app

                  01-25 09:43:10.963: VERBOSE/NearbyListFragment(3060): IN ON CREATE
                  01-25 09:43:10.963: VERBOSE/LocationManagerService(1329): getProviders
                  01-25 09:43:10.963: VERBOSE/LocationManagerService(1329): getProviders
                  01-25 09:43:10.973: VERBOSE/LocationManagerService(1329): getProviders
                  01-25 09:43:10.983: VERBOSE/NearbyListFragment(3060): Provider: gps
                  01-25 09:43:10.983: DEBUG/LocationManager(3060): requestLocationUpdates: provider = gps, listener = co.fusionweb.dealsplus.app.NearbyItems$NearbyListFragment$MyLocationListener@46ef4680
                  01-25 09:43:10.983: DEBUG/GpsLocationProvider(1329): setMinTime 1
                  01-25 09:43:10.983: VERBOSE/NearbyListFragment(3060): NO Last Location found
                  01-25 09:43:10.983: VERBOSE/LocationManagerService(1329): _requestLocationUpdates: listener = Receiver{47421e68 Listener android.os.BinderProxy@47421a68}
                  01-25 09:43:11.003: VERBOSE/countingFragment(3060): IN ON CREATE VIEW
                  01-25 09:43:11.003: WARN/GpsLocationProvider(1329): Duplicate add listener for co.fusionweb.dealsplus
                  01-25 09:43:11.013: VERBOSE/ScrollListener(3060): In Constructor
                  01-25 09:43:11.013: VERBOSE/ScrollListener(3060): Scrolling
                  01-25 09:43:11.033: DEBUG/GpsLocationProvider(1329): startNavigating
                  01-25 09:43:11.043: DEBUG/lib_locapi(1329): loc_eng_set_qos_time_out(standalone = 60, agps = 89)
                  01-25 09:43:11.043: DEBUG/lib_locapi(1329): loc_eng_set_qos_accuracy(accuracy = 50)
                  01-25 09:43:11.043: VERBOSE/lib_locapi(1329): persist.radio.agps.mode: []
                  01-25 09:43:11.043: DEBUG/lib_locapi(1329): loc_eng_set_position mode, client = 1, interval = 1, mode = 1
                  01-25 09:43:11.043: VERBOSE/lib_locapi(1329): loc_eng_ioctl called: client = 1, ioctl_type = 2
                  01-25 09:43:11.043: VERBOSE/locapi_rpc_glue(1329): loc_ioctl
                  01-25 09:43:11.043: DEBUG/RPC(1329): written RPC packet size: [96]
                  01-25 09:43:11.043: DEBUG/RPC(1329): read RPC packet
                  01-25 09:43:11.043: DEBUG/RPC(1329): read RPC packet size: [28]
                  01-25 09:43:11.043: VERBOSE/locapi_rpc_glue(1329): loc_api_sync_ioctl: select_id = 0, loc_ioctl returned 0
                  01-25 09:43:11.043: DEBUG/RPC(1329): read RPC packet
                  01-25 09:43:11.043: DEBUG/RPC(1329): read RPC packet size: [80]
                  01-25 09:43:11.043: VERBOSE/locapi_rpc_glue(1329): Callback received: 80 (cb_id=0x5310000 handle=1)
                  01-25 09:43:11.043: DEBUG/RPC(1329): written RPC packet size: [28]
                  01-25 09:43:11.043: VERBOSE/lib_locapi(1329): loc_eng_ioctl result: client = 1, ioctl_type = 2, SUCCESS
                  01-25 09:43:11.043: DEBUG/lib_locapi(1329): loc_eng_start
                  01-25 09:43:11.043: DEBUG/locapi_rpc_glue(1329): loc_start_fix
                  01-25 09:43:11.043: DEBUG/RPC(1329): written RPC packet size: [44]
                  01-25 09:43:11.043: DEBUG/RPC(1329): read RPC packet
                  01-25 09:43:11.053: DEBUG/RPC(1329): read RPC packet size: [28]
                  01-25 09:43:11.103: DEBUG/RPC(1329): read RPC packet
                  01-25 09:43:11.103: DEBUG/RPC(1329): read RPC packet size: [80]
                  01-25 09:43:11.113: VERBOSE/locapi_rpc_glue(1329): Callback received: 100 (cb_id=0x5310000 handle=1)
                  01-25 09:43:11.113: VERBOSE/lib_locapi(1329): process_deferred_action: pthread_cond_wait returned
                  01-25 09:43:11.113: DEBUG/lib_locapi(1329): loc_eng_report_status: GPS_STATUS_SESSION_BEGIN
                  01-25 09:43:11.113: DEBUG/lib_locapi(1329): loc_eng_report_status: update status
                  01-25 09:43:11.113: VERBOSE/GpsLocationProvider(1329): reportStatus status: 1
                  01-25 09:43:11.113: DEBUG/GpsLocationProvider(1329): Acquiring wakelock
                  01-25 09:43:11.123: DEBUG/RPC(1329): written RPC packet size: [28]
                  01-25 09:43:11.183: DEBUG/PowerManagerService(1329): New lightsensor value:40, lcdValue:77
                  01-25 09:43:11.273: DEBUG/RPC(1329): read RPC packet
                  01-25 09:43:11.273: DEBUG/RPC(1329): read RPC packet size: [80]
                  01-25 09:43:11.273: VERBOSE/locapi_rpc_glue(1329): Callback received: 100 (cb_id=0x5310000 handle=1)
                  01-25 09:43:11.273: VERBOSE/lib_locapi(1329): process_deferred_action: pthread_cond_wait returned
                  01-25 09:43:11.273: DEBUG/lib_locapi(1329): loc_eng_report_status: GPS_STATUS_ENGINE_ON
                  01-25 09:43:11.273: DEBUG/lib_locapi(1329): loc_eng_report_status: update status
                  01-25 09:43:11.273: VERBOSE/GpsLocationProvider(1329): reportStatus status: 3
                  

                  logcat 的 android SDK 位置部分不斷重復(fù)它們自己.我已經(jīng)嘗試了所有我能想到并在 google 和 stackoverflow 上看到的東西.順便說一句,我已經(jīng)能夠使用 API 9 中提供的 requestSingleUpdate 并按照指南 深入了解位置 但我需要它在 2.1 或 2.2 及更高版本上使用舊的 SDK.因此,如果您有任何提示或想了解更多信息,請(qǐng)告訴我.提前致謝.

                  And the android SDK location parts of the logcat keep repeating them selves. I have tried everything that i can think of and have seen on google and stackoverflow. Als just as a side note i have been able to get it to work on a 2.3 device using the requestSingleUpdate which is available in API 9 and by following the guide A Deep Dive into Location but i need it to work on 2.1 or 2.2 and higher using the old SDK. SO if you have any hints or would like to know more please let me know. Thanks in advance.

                  推薦答案

                  看起來你的設(shè)置應(yīng)該可以工作,因?yàn)樗鼪]有,我會(huì)讓你的例子盡可能簡單以便排除故障.我會(huì)讓你的請(qǐng)求看起來像

                  It looks like you setup should work, since it doesn't, I would make your example as simple as possible in order to troubleshoot. I would make your request look like

                  requestLocationUpdates(LocationManager.GPS_PROVIDER, 0, 0, locationListener);
                  requestLocationUpdates(LocationManager.NETWORK_PROVIDER, 0, 0, locationListener);
                  

                  這樣您就可以獲得所有可能的更新.并注釋掉關(guān)于獲取最后一個(gè)已知位置的部分.現(xiàn)在還不需要.

                  This way you get ALL the updates possible. And comment out the part about getting the last known location. It's not needed yet.

                  然后在onLocationChanged()中,只要有

                  Log.v(TAG, "IN ON LOCATION CHANGE, lat=" + latitude + ", lon=" + longitude);
                  

                  注釋掉其余部分,以便讓您的聽眾保持活躍.這應(yīng)該為您提供真實(shí)設(shè)備上的更新流.在模擬器上,您需要使用 DDMS,并且每次按下發(fā)送都會(huì)獲得一次 GPS 更新.

                  Comment out the rest so that you keep your listener active. This should give you a stream of updates on a real device. On the emulator, you'll need to use DDMS, and you'll get one GPS update each time you press send.

                  這篇關(guān)于OnLocationChanged 回調(diào)永遠(yuǎn)不會(huì)被調(diào)用的文章就介紹到這了,希望我們推薦的答案對(duì)大家有所幫助,也希望大家多多支持html5模板網(wǎng)!

                  【網(wǎng)站聲明】本站部分內(nèi)容來源于互聯(lián)網(wǎng),旨在幫助大家更快的解決問題,如果有圖片或者內(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 獲取用戶的當(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(如何檢測位置提供者?GPS 或網(wǎng)絡(luò)提供商)

                      <bdo id='4j8Do'></bdo><ul id='4j8Do'></ul>

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

                      <small id='4j8Do'></small><noframes id='4j8Do'>

                        • <legend id='4j8Do'><style id='4j8Do'><dir id='4j8Do'><q id='4j8Do'></q></dir></style></legend>
                              <tbody id='4j8Do'></tbody>
                            主站蜘蛛池模板: 天天艹日日干 | 成人伊人| 日一区二区三区 | 人妖一区| 日韩三级一区 | 欧美日韩久久 | 日韩在线播放第一页 | 亚洲精品一区二区 | 亚洲成人精品一区 | 国产在线小视频 | 一区二区三区视频在线免费观看 | 特级丰满少妇一级aaaa爱毛片 | 日韩久久久久 | 永久免费av| 99热.com| 欧美成人免费在线视频 | 日韩国产在线 | 国产xxx在线观看 | 免费观看黄网站 | 国产精品成人国产乱一区 | 精品欧美乱码久久久久久 | 国产精品久久久久久久久久 | 在线一区视频 | 综合久久国产 | 国产高清美女一级a毛片久久w | 欧美亚洲视频在线观看 | 亚洲电影在线播放 | 国产精品免费视频一区 | 国产精品国产精品 | 精品一二三 | 中文二区 | 久久久精品网 | 亚洲人va欧美va人人爽 | 免费视频一区 | 521av网站| 国产激情视频网址 | 亚洲一区二区三区在线视频 | 亚洲高清视频在线观看 | 午夜视频在线观看视频 | 欧美mv日韩mv国产网站91进入 | 亚洲视频一区在线观看 |