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

      <legend id='zdBDG'><style id='zdBDG'><dir id='zdBDG'><q id='zdBDG'></q></dir></style></legend>
    1. <tfoot id='zdBDG'></tfoot>

        <bdo id='zdBDG'></bdo><ul id='zdBDG'></ul>

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

        使用 LocationClient 定期获取更新最省电的方法是什

        时间:2023-09-01
        <tfoot id='rKSuj'></tfoot>

            1. <legend id='rKSuj'><style id='rKSuj'><dir id='rKSuj'><q id='rKSuj'></q></dir></style></legend>
                  <tbody id='rKSuj'></tbody>
                  <bdo id='rKSuj'></bdo><ul id='rKSuj'></ul>
                  <i id='rKSuj'><tr id='rKSuj'><dt id='rKSuj'><q id='rKSuj'><span id='rKSuj'><b id='rKSuj'><form id='rKSuj'><ins id='rKSuj'></ins><ul id='rKSuj'></ul><sub id='rKSuj'></sub></form><legend id='rKSuj'></legend><bdo id='rKSuj'><pre id='rKSuj'><center id='rKSuj'></center></pre></bdo></b><th id='rKSuj'></th></span></q></dt></tr></i><div id='rKSuj'><tfoot id='rKSuj'></tfoot><dl id='rKSuj'><fieldset id='rKSuj'></fieldset></dl></div>

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

                  本文介绍了使用 LocationClient 定期获取更新最省电的方法是什么?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

                  问题描述

                  我正在考虑设置两个单独的警报来每小时收集用户的位置数据,一个每 59 分钟触发一次以连接"客户端,另一个用于实际获取位置,然后断开客户端.

                  I am thinking about having two separate alarms to gather a user's location data every hour, one that goes off every 59 minutes to "connect" the client and a second to actually get the location and then subsequently disconnect the client.

                  在电池寿命方面,如果获取用户的位置将成为应用程序的主要消耗,我还应该考虑做些什么?或者,是否有不同的方法来设置两个警报?我最初只有一个警报,但执行 (!mLocationClient.isConnected) 然后进行连接检查并没有给客户端足够的时间来连接.

                  In terms of battery life, is there anything else I should consider doing if getting the user's location will be the primary drain of the app? Or, is there a different approach to having two alarms? I originally only had a single alarm, but performing a (!mLocationClient.isConnected) then connect check does not give the client enough time to connect.

                  感谢您的洞察力.

                  两个警报会像这样响起:

                  The two alarms would go off something like this:

                  private int PERIODIC_UPDATE = 60000*60;  //gets location and disconnects every hour
                  private int PERIODIC_RECONNECTION_UPDATE = 60000*59;  //connects 1 minute before getLocation call
                  
                      Timer toReconnect = new Timer();
                      toReconnect.schedule(new TimerTask() {
                  
                          @Override
                          public void run() {
                              mLocationClient.connect();
                          }
                      }, 5000, PERIODIC_RECONNECTION_UPDATE);
                  
                      Timer theTimer = new Timer(); 
                      theTimer.schedule(new TimerTask(){
                          @Override
                          public void run() {
                              try {
                                  if(!mLocationClient.isConnected()) {
                                      mLocationClient.connect();
                                      //This will not have much affect because cannot so quickly, will remove. 
                                  }
                  
                                  Location theLocation = mLocationClient.getLastLocation();
                                  if(theLocation!=null) {
                                      checkPostLocation(theLocation); 
                  
                                      mLocationClient.disconnect();
                                  }
                              } catch (Exception e) {
                                  e.printStackTrace();
                              }   
                          }}, 5000, PERIODIC_UPDATE);
                  

                  推荐答案

                  你真的需要跟踪用户吗?

                  Do you actually need to track the user?

                  如果只是关于 UI,则使用 getLastKnownLocation(PASSIVE_PROVIDER),假设他们在其他地方使用手机上的定位服务,您应该会得到一些半准确的信息.

                  If it's just about UI, then use getLastKnownLocation(PASSIVE_PROVIDER) and you should get something semi-accurate assuming they used location services on their phone somewhere else.

                  如果您需要实际对用户进行三角测量,请实现不同的供应商使用不同的电池.被动<网络<全球定位系统.

                  If you need to actually triangulate the user, realize the different providers use different battery. Passive < Network < GPS.

                  定位用户越多,GPS 消耗的电量和时间就越多.

                  The more you locate the user, the more battery with GPS taking the most battery and time.

                  按计划启动服务,1 小时或其他任何时间,只需要一项服务.最多只能活 1 分钟(或更短),收听所有位置提供商.在分钟或准确度足够好后,您保存结果并关闭服务.

                  Start the service by intent one a schedule, 1 hour or whatever, only one service necessary. Only live for a maximum of 1 minute (or less), listen on all Location providers. After the minute or accuracy is good enough, you save the result and shut down the service.

                  这篇关于使用 LocationClient 定期获取更新最省电的方法是什么?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持html5模板网!

                  上一篇:将一个 LatLng 向另一个 LatLng 移动 5 米 下一篇:IOS:将图像添加到自定义 MKAnnotationview

                  相关文章

                  最新文章

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

                    1. <legend id='ZDMwH'><style id='ZDMwH'><dir id='ZDMwH'><q id='ZDMwH'></q></dir></style></legend>
                      • <bdo id='ZDMwH'></bdo><ul id='ZDMwH'></ul>
                    2. <small id='ZDMwH'></small><noframes id='ZDMwH'>