android-doze

Doze mode handling

戏子无情 提交于 2019-12-23 12:04:03
问题 I am working on an application which spawns some services in the background using AlarmManager. Timing is very crucial to our application and the functionality can't wait for the next maintenance window to occur. Asking a user to white-list the application is not an issue but doesn't fix the issue of suspending alarms. Also battery consumption is not that big of an issue as well. First possible solution that came to my mind was to spawn an always running foreground service to handle the

Intent Service not working in doze mode

落爺英雄遲暮 提交于 2019-12-23 04:08:08
问题 One of my peer developer has written an intent service that makes an API call and then sleeps for 2 mins. After waking up, it sends again. Below is the code: public class GpsTrackingService extends IntentService { .... @Override protected void onHandleIntent(Intent intent) { do{ try{ //make API call here //then go to sleep for 2 mins TimeUnit.SECONDS.sleep(120); } catch(InterruptedException ex){ ex.printStackTrace(); } } while (preferences.shouldSendGps()); //till the user can send gps. } ...

BroadcastReceiver has no internet access

巧了我就是萌 提交于 2019-12-13 01:36:18
问题 I'm facing a problem with my broadcast receiver. I have set an alarm for 6am, it has to fire my broadcast receiver, which only has to download some data from internet and process it. If I set the alarm for 3pm, for example, it works fine. But the problem is at 6am, it fails downloading because it does not have network connectivity. I perform a partial wake lock before attempting download. Can it be related to this? Does the phone enter some deep sleep and partial wake lock is not enough? What

Doze Mode, Battery Optimization whitelist, AlarmManager more frequent than 9 mins

可紊 提交于 2019-12-12 20:19:52
问题 I'm creating an app to connect with BT device to collect heath data (i.e.: body temperature). The sensor sleeps for periodic time and wakes up only for limited window of time to connect. I've tried to create AlarmManager which fires Foreground Service with setExactAndAllowWhileIdle() and it is working as expected for periods higher than 9 minutes, but below 9 minutes it goes to doze mode and do not fire AlarmManager BroadcastReceiver. From documentation I do not understand if adding app to

Push notifications are delayed in Android Doze mode

久未见 提交于 2019-12-12 11:19:36
问题 I am putting my Android device to sleep via adb: adb shell dumpsys battery unplug adb shell dumpsys deviceidle step <-- repeat until state is IDLE Then I am sending the following JSON: { "to":"dYA7tVZrfag:APA91bFVqddVcJHnr_7ZhgNC5iu4Y6XKcLbSVD4DlZgfjMKwKvZhJHiKR4DIzpMrX8zUL15C_adfyEcrlI9q6zOFqFs_zwNPTVIDm-v20ZK0qgagKYGaQE1OPBqdH4P_JHYIXOIS3gfn", "priority": "high", "data":{ "test0":"test0", "test1":"test1" } } Result: Nothing... until I wake up the device, then I get all the messages queued.

Doze mode sleeps Google's Geofence sample application

随声附和 提交于 2019-12-12 06:45:20
问题 I have an android application that uses Geofence and I'm having a hard time overcoming Doze mode. My manifest has the WAKE_LOCK permission and seven setNotificationResponsiveness to 0 for each region. I even changed PendingIntent to BroadcastReceiver but the app literally sleeps or is dead after a while with the deleted smartphone screen. I've already tried using LocationRequest LocationRequest.setFastestInterval(1000); LocationRequest.setInterval(2000); Even so, I did not succeed. Has anyone

Why is Network access in my geofence broadcast receiver unreliable?

不羁岁月 提交于 2019-12-11 13:44:37
问题 Use case: When geofence triggers we need to contact server ASAP. We have solved this with an implicit BroadcastReceiver calling a Service for several years, but problematic in new versions due to Doze and Oreo background restrictions. Attempted fixes: We moved geofence registering from implicit -> explicit broadcast receiver to get around the "background mode" restriction. We tried to do it as in Googles examples, i.e. the broadcast receiver calling enqueueWork() on a JobIntentService . The

AlarmManager not set or not firing on Marshmallow after certain time

只愿长相守 提交于 2019-12-11 12:58:08
问题 I have been successfully using the following construct to start an AlarmManager in some of my apps upto Android 5: Intent serviceIntent = new Intent(context, MyService.class); PendingIntent pi = PendingIntent.getService(context, alarmId, serviceIntent, PendingIntent.FLAG_UPDATE_CURRENT); DateTime inMinutes = (new DateTime()).plusMinutes(60); AlarmManager am = (AlarmManager) context.getSystemService(Context.ALARM_SERVICE); am.set(AlarmManager.RTC_WAKEUP, inMinutes.getMillis(), pi); But since

Services stopping automatically from android OS 5.1.1

狂风中的少年 提交于 2019-12-11 05:27:29
问题 I am working on an application related to Voip & IM (chatting application). Till android OS 5.0 it is working good and no issues from client also. But from android OS 5.1.1 onwards we are facing issues. Issues: If the app is in foreground and if device goes to sleep mode it is working good. If the app is in background and if device goes to sleep mode after 10 minutes all the services are stopping automatically . Testing: For testing I created one timer task to print logs for every 1 minute.

Do the latest Android updates disable the battery optimization whitelist?

醉酒当歌 提交于 2019-12-10 13:58:33
问题 TL;DR Did the 'June 5, 2017' security updates for Android 7.1.2 cause Android to start ignoring the battery optimization whitelist (i.e. the thing that's meant to let an app disable Doze mode)? And if so, how can an app now programmatically disable Doze mode if it has a use-case that requires the CPU and wifi be kept continuously active? Context I have an Android app which supports casting local audio files to a networked Chromecast receiver (using an embedded HTTP server to stream the file