-
Notifications
You must be signed in to change notification settings - Fork 105
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
startForeground & Keeping WebViews Alive #17
Comments
Example of startForeground being used in a Cordova plugin: |
@Red-Folder I created a plugin based on your sample that does what I describe above: Works great. |
Good job. Well done. Have you thought about merging this code into the bgs-core repository? |
Enhancement: Add startForeground as an option. Some notes on startForeground here -> http://developer.android.com/reference/android/app/Service.html#onStart(android.content.Intent,int) Note that I don't specifically think it is a valid scenario to use the service to keep the app open - that's just not how the Android lifecycle is designed (from my understanding) |
I've been using startForeground as a method to keep the app alive for a few months now. You're correct that it is not designed for keeping the app open, but it does decrease the likelyhood that the app will be killed due to memory pressure because the OS assumes the user is using the functionality actively in the foreground. My particular use case is for a VoIP app that uses webRTC. I display a notification that shows the current VoIP status, call status, etc, so it works nicely for me. |
Merging in of old repo issue -> Red-Folder/Cordova-Plugin-BackgroundService#40 |
(Notes to self) For a custom Notification, see http://developer.android.com/guide/topics/ui/notifiers/notifications.html (scroll to the bottom and Custom Notification Layouts) Probably best in first incarnation to follow Android standard Notification setup. Then an additional enhancement to look at custom. Gut feel is that you wouldn't be able to include a webview into a custom notification (bit of a shame). |
@lylepratt On Galaxy S6 Edge, I don't know if it is a Samsung issue that even after creating a background service STICKY and acquiring the partial wakelock, the app once killed by the process manager never restarts. It restarts only once the phone is rebooted. The same does not happens on stock android though. Thanks to you for providing a "foreground" service option. After using this in combination with "partial wakelock" i have ensured that even on galaxy S6 edge the service keeps on running without getting killed. |
@lylepratt Also i would like to ask you, if there is any way to make the service run as a foreground service but without any notification on the notification area? |
I think the core requirement of a "foreground" service is that it HAS to Relevant stackoverflow post:
|
@lylepratt ok. thanks for the help. In my service I had to additionally take wakelock as described in Red-Folder/Cordova-Plugin-BackgroundService#52 by vista-54. However, I see that this is eating up a lot of battery. Is there any alternative? |
I'm interested in using this plugin to create a "dummy" service as described in this StackOverflow post in order to prevent a WebView from being killed (so javascript continues to execute):
http://stackoverflow.com/questions/12226703/backgrounding-phonegap-and-the-relationship-between-activity-process-and-servi
It looks like in order for the above to work, I have to use
startForeground
which requiresonStartCommand
. Basically my purpose for this is because I'm using Sip.JS & WebRTC to create a VoIP phone and need to be able to continue to receive calls in the background (so can't have the webview getting killed).It looks like all I need to do is implement
onStartCommand
andstartForeground
to accomplish this, but I was curious if you had any additional thoughts or experience on keeping WebViews alive.Thanks,
Lyle
The text was updated successfully, but these errors were encountered: