0
我的應用每15分鐘向我的服務器發送一次GPS位置數據。這個功能是應用程序的核心目的。電池優化白名單不會阻止推遲使用我的應用的打盹
但是,當手機關閉並且未被使用時,GPS日誌記錄會逐漸消失。 GPS記錄之間的時間爲15分鐘一段時間,然後是1小時,2小時,4小時,6小時,然後在移動手機或打開它時恢復到15分鐘。
這似乎是由於Android 6中引入的打盹模式。我將該應用添加到電池優化白名單,但這並沒有什麼區別,despite the documentation claiming otherwise。
- 爲什麼白名單在這種情況下不起作用?
我應該怎麼做呢? Wakelock會定期延遲,從而防止打瞌睡?
// Request frequent location updates. Intent locationUpdateIntent = new Intent(this, StoreLocationService.class); locationUpdateIntent.setAction(MyAwesomeActionName); LocationRequest locationRequest = LocationRequest.create(); locationRequest.setPriority(LocationRequest.PRIORITY_HIGH_ACCURACY); locationRequest.setInterval(15 * 60 * 1000); // 15 minutes locationRequest.setFastestInterval(15 * 60 * 1000); // 15 minutes LocationServices.FusedLocationApi.requestLocationUpdates( mGoogleApiClient, locationRequest, PendingIntent.getService(this, 0, locationUpdateIntent, 0));