I read many questions here about doze mode like Android doze mode, Android N Doze mode - how to keep background download and processing?, Wakelock and doze mode and many others. But in many replies, opinions is different. I can't test it by myself (emulator does not support my processor, and my only test device is android 5.1). I would like to know the next situation. I have an activity, which controls the media player. On devices with android 6.0 and higher it wouldn't work as expected cause of doze mode. As many solutions says to prevent doze mode it should start a service in separate process in foreground and control media player from there. The question is: if i start foreground service with partial wake lock in separate process, which would do nothing except showing notification, and leave controls to media player in my activity, should it prevent the doze mode? Or maybe there any other ways except keep the screen on from window manager?
Android doze mode and foreground service
2.2k Views Asked by kara4k At
1
There are 1 best solutions below
Related Questions in ANDROID
- Delay in loading Html Page(WebView) from assets folder in real android device
- MPAndroidChart method setWordWrapEnabled() not found
- Designing a 'new post' android activity
- Android :EditText inside ListView always update first item in the listview
- Android: Transferring Data via ContentIntent
- Wrong xml being inflated android
- AsyncTask Class
- Unable to receive extras in Android Intent
- Website zoomed out on Android default browser
- Square FloatingActionButton with Android Design Library
- Google Maps API Re-size
- Push toolbar content below statusbar
- Android FragmentPagerAdapter Circular listview
- Layout not shifting up when keyboard is open
- auDIO_OUTPUT_FLAG_FAST denied by client can't connect to localhost
Related Questions in WAKELOCK
- Wake locks on my service and third party programs not working at all
- Java Android service keep device awake to receive serial port commands
- Android Notification not fired when phone sleeps for a long time
- How to use PowerManager.ACQUIRE_CAUSES_WAKEUP
- is impact of acquiring cpu wake lock increases by no of applications holding it in android?
- How to use getSystemService in widget on android?
- Device not locked after WakeLock
- FLAG_KEEP_SCREEN_ON not undimming the screen
- Should I use acquire_causes_wakeup instead of Partial_Wake_Lock?
- Why does my IntentService not require a WakeLock?
- PowerManager.PARTIAL_WAKE_LOCK android
- Problems with releasing wakelock with flag ON_AFTER_RELEASE
- battery conservation and AlarmManager performance
- Is there any type of partial wake lock mechanism in ios?
- Dim screen while user inactive
Related Questions in FOREGROUND-SERVICE
- android displaying multiple activity in saved state when notification click
- Auto Upload Service
- Oreo - Foreground service does not show foreground notification
- how to get package name of application being displayed on screen in a foreground service, android?
- Is there any way to run a foreground service in react native?
- Is there any way of waking screen pragmatically via service?
- Does a Pending Intent have a lifetime?
- Delphi cannot start Android Service above Android 8 version
- Android Foreground Service() issue
- Android 11 - foregroundService's onTaskRemoved is trigged when home button pressed
- Foreground service vs WorkManager for location tracking
- Ensure foreground service is not cached after 30 minutes
- Android slows down foreground service response during sleep
- What is the proper way to stop a service running as foreground
- Run an app in foreground & background (Time sharing)
Related Questions in DOZE
- Overcome doze in android for audio streaming
- Run Coroutine with delay in doze mode
- How to make a periodic background work (15 mins periodic interval) to run indefinitely on Oreo and later?
- Dealing with Android-Doze mode on my BLE monitoring app while user's sleeping
- Android: Alarm triggered and turning on screen, but the alarm activity gets closed
- Getting location updates when in idle mode
- What is Android process "ash" & how to prevent it from hibernating my app? (Android 7.0 doze mode)
- No internet connection during doze mode
- Android doze mode influence
- How to keep internet connection alive for a long time on android?
- firebase_messaging not working in android 10 e latter after long period of inactivity of the app in FLUTTER
- MediaPlayer: Is whitelist battery optimizations allowed?
- setAlarmClock() fires too late in doze mode
- Issue with using Ably in Doze mode
- WebSocket in ForegroundService stops
Trending Questions
- UIImageView Frame Doesn't Reflect Constraints
- Is it possible to use adb commands to click on a view by finding its ID?
- How to create a new web character symbol recognizable by html/javascript?
- Why isn't my CSS3 animation smooth in Google Chrome (but very smooth on other browsers)?
- Heap Gives Page Fault
- Connect ffmpeg to Visual Studio 2008
- Both Object- and ValueAnimator jumps when Duration is set above API LvL 24
- How to avoid default initialization of objects in std::vector?
- second argument of the command line arguments in a format other than char** argv or char* argv[]
- How to improve efficiency of algorithm which generates next lexicographic permutation?
- Navigating to the another actvity app getting crash in android
- How to read the particular message format in android and store in sqlite database?
- Resetting inventory status after order is cancelled
- Efficiently compute powers of X in SSE/AVX
- Insert into an external database using ajax and php : POST 500 (Internal Server Error)
Popular Questions
- How do I undo the most recent local commits in Git?
- How can I remove a specific item from an array in JavaScript?
- How do I delete a Git branch locally and remotely?
- Find all files containing a specific text (string) on Linux?
- How do I revert a Git repository to a previous commit?
- How do I create an HTML button that acts like a link?
- How do I check out a remote Git branch?
- How do I force "git pull" to overwrite local files?
- How do I list all files of a directory?
- How to check whether a string contains a substring in JavaScript?
- How do I redirect to another webpage?
- How can I iterate over rows in a Pandas DataFrame?
- How do I convert a String to an int in Java?
- Does Python have a string 'contains' substring method?
- How do I check if a string contains a specific word?
According to this SO question and answer:
- Source (sec_aw)
It looks like using a foreground service prevents the app from being killed by Doze.
Please note though, that some vendors (I know of Samsung, but there are probably others) create their own RAM conservation/battery saving tools. These may exhibit patterns completely different from Doze, and there's usually a bunch of other hoops to jump through. You are not guaranteed to get the same behavior on these devices either - they may be more or less aggressive, and the more aggressive ones tend to be worse for keeping services or whatever alive.
There's also no universal way to deal with these, but someone has made an entire website dedicated to showing what vendors are problematic, as well as potential workarounds. Note that the majority of the problematic vendors only yield end-user solutions, which means you (the developer) have no way to fix it without the user doing something.
While this is unfortunate, that's pretty much what happens when companies implement their own versions of Android. Also, from my own experience (primarily as a user rather than a dev) on a Samsung phone, the settings aren't always respected and still causes annoying behavior.
Anyway, as long as Doze is present, foreground services should be fine. On other vendors, however, all bets are off and you're at the mercy of the vendor's implementation of some type of optimization system. On certain exposed operating systems (again, see the website linked earlier), you also have no choice but to ask the user to fix certain settings to keep stuff alive.