谷歌播放服务机器人。如果禁用无线客户端的位置不更新位置 [英] Google Play Services for Android. Location client not update location if wifi disabled

查看:151
本文介绍了谷歌播放服务机器人。如果禁用无线客户端的位置不更新位置的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我们与LocationClient和IntentService应用程序请求更新位置。 位置不更新在所有如果用户禁用无线网络的手机设置。

Our app request update location with LocationClient and IntentService. Location doesn't update at all if user disable wifi in phone settings.

我们试图用PRIORITY_HIGH_ACCURACY和位置更新的测试应用程序时的WiFi关闭。

We tried to test app with PRIORITY_HIGH_ACCURACY and location updates when wifi disabled.

如果用户的地方移动同样的问题,即没有可用的WiFi网络。

The same issue if user moving in the place where no wifi networks available.

我认为正确的做法是用其他手机的传感器(如GPS)进行更新的位置,如果手机不能带wifi更新的位置。

I think correct behavior is use other phone sensors (like GPS) for update location if phone can not update location with wifi.

重现步骤:

  1. 开始更新位置与待处理的意图。随着参数

  1. Start update location with pending intent. With parameters

LocationRequest request = LocationRequest.create()
        .setPriority(LocationRequest.PRIORITY_BALANCED_POWER_ACCURACY)
        .setInterval(5 * 60 * 1000)
        .setFastestInterval(60*1000)
        .setSmallestDisplacement(70);

  • 禁用无线网络的手机设置,或在该国去电话,其中可用的WiFi网络。

  • Disable wifi in phone settings or go with phone in the country where no wifi networks available.

    在测试了Android 4.4系统,4.3,4.1,4.0,2.3.3。 (Nexus7,Nexus4,三星GS2,HTC野火等)

    Tested on Android 4.4, 4.3, 4.1, 4.0, 2.3.3. (Nexus7, Nexus4, Samsung GS2, HTC Wildfire and others)

    public class TrackerService extends IntentService {
        private void startUpdateLocation() {
            PendingIntent pendingIntent = PendingIntent.getService(getApplicationContext(),
                0, new Intent(ACTION_LOCATION_UPDATED), 0);
            LocationRequest request = LocationRequest.create()
                .setPriority(LocationRequest.PRIORITY_BALANCED_POWER_ACCURACY)
                .setInterval(5 * 60 * 1000)
                .setFastestInterval(60*1000)
                .setSmallestDisplacement(70);
    
            getLocationClient().requestLocationUpdates(request, pendingIntent);
            Log.d(Utils.getMethodName(), "Location update started");
        }
    
        private LocationClient getLocationClient() {
            if (mLocationClient != null && mLocationClient.isConnected()) return mLocationClient;
            mLocationClient = new LocationClient(this,
                new GooglePlayServicesClient.ConnectionCallbacks() {
                    @Override
                    public void onConnected(Bundle bundle) {
                        Log.d(Utils.getMethodName(), "Location client. Connected");
                    }
    
                    @Override
                    public void onDisconnected() {
                        Log.d(Utils.getMethodName(), "Location client. Disconnected");
                    }
                },
                new GooglePlayServicesClient.OnConnectionFailedListener() {
                    @Override
                    public void onConnectionFailed(ConnectionResult connectionResult) {
                        throw new IllegalStateException("Failed connection to location manager " + connectionResult.toString());
                    }
                }
            );
            mLocationClient.connect();
            try {
                while (mLocationClient.isConnecting()) {
                    Thread.sleep(200);
                }
            } catch (InterruptedException e) {
                throw new IllegalStateException("Thread interrupted", e);
            }
            return mLocationClient;
        }
    }
    

    我试图发送错误报告<一href="https://$c$c.google.com/p/android/issues/detail?id=63110">https://$c$c.google.com/p/android/issues/detail?id=63110

    Android的开发者也没有办法。

    Developers of Android can't help.

    在谷歌播放服务有关的错误在哪里可以举报?

    是不是在谷歌播放服务中的错误?

    你能提供什么变通

    我们不希望使用PRIORITY_HIGH_ACCURACY,因为它耗尽手机电池。我们的应用程序追踪手机位置,它不应该依赖从WiFi设置和WiFi网络的可用性。

    We don't want use PRIORITY_HIGH_ACCURACY because it drain phone battery. Our application tracking phone location and it shouldn't depends from wifi settings and wifi networks availability.

    推荐答案

    我找到了解决办法。

    谷歌改变文档位置客户端。现在它说:

    Google changed documentation for Location Client. Now it says:

    公共静态最终诠释PRIORITY_BALANCED_POWER_ACCURACY

    public static final int PRIORITY_BALANCED_POWER_ACCURACY

    用于与setPriority(int)的要求块级精度。

    Used with setPriority(int) to request "block" level accuracy.

    块级的精度被认为是约100米的精度。   使用粗糙的精确性,如这通常耗电更少。

    Block level accuracy is considered to be about 100 meter accuracy. Using a coarse accuracy such as this often consumes less power.

    使用粗精度 - 我认为这意味着位置客户端不使用GPS的更新位置,如果优先级PRIORITY_BALANCED_POWER_ACCURACY

    Using a coarse accuracy - I think it means that Location Client doesn't use GPS for update location if priority is PRIORITY_BALANCED_POWER_ACCURACY.

    因此​​,对于使用GPS的你应该使用PRIORITY_HIGH_ACCURACY。

    So for using GPS you should use PRIORITY_HIGH_ACCURACY.

    这篇关于谷歌播放服务机器人。如果禁用无线客户端的位置不更新位置的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

  • 查看全文
    登录 关闭
    扫码关注1秒登录
    发送“验证码”获取 | 15天全站免登陆