Meine App muss den Benutzer kontinuierlich verfolgen. Dafür habe ich eine LocationListener
, die fortlaufend Ortsupdates erhalten soll. Das Problem ist, wenn der Bildschirm ausgeschaltet ist, erhält es keine Updates.Android empfängt keine Standortaktualisierungen, wenn der Bildschirm gesperrt ist
Ich habe versucht, eine Teil-Wach-Sperre und fügte hinzu:
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();
Aber es erhält noch nicht Updates.
Werfen Sie einen Blick [hier] (http://Stackoverflow.com/a/14478281/312312) Es sollte Ihnen helfen – Lefteris