屏幕锁定时Android未收到位置更新

时间:2014-03-04 08:18:02

标签: android google-play-services wakelock locationlistener

我的应用必须持续跟踪用户。为此,我有LocationListener,它应该连续接收位置更新。问题是当屏幕关闭时,它不会收到任何更新。

我尝试添加部分唤醒锁:

mLocationRequest = LocationRequest.create();
        mLocationRequest.setInterval(LocationUtils.UPDATE_INTERVAL_IN_MILLISECONDS);
        mLocationRequest.setPriority(LocationRequest.PRIORITY_HIGH_ACCURACY);
        mLocationRequest.setFastestInterval(LocationUtils.FAST_INTERVAL_CEILING_IN_MILLISECONDS);
        mLocationClient = new LocationClient(ADS.getAppContext(), new LocationGatherer(), new LocationGatherer());
        mLocationClient.connect();
        PowerManager pm = (PowerManager) ADS.getAppContext().getSystemService(Context.POWER_SERVICE);
        PowerManager.WakeLock wl = pm.newWakeLock(PowerManager.PARTIAL_WAKE_LOCK, "My Tag");
        wl.acquire();

但它仍然没有收到更新。

0 个答案:

没有答案