Run mobile web application in the background as a service - android

I am working on a HTML5 mobile web application that runs in browser. I want this app to receive server sent push notifications even when the browser/web app is closed. For that reason, I would want my mobile web app to run in the background once visited. I mean I will store some code on mobile maybe cache etc. So the question is that is it possible to run mobile web app as a service on mobile device?

Yes, in iOS, you can let your web application run in background (when it is closed). You have to give some settings to your application. However, in background, the UI threads is suspended, all commands in UI thread will be cached, until you open your application again. So remember to process your services in background threads, else they will be stucked with UI thread.
In Android, you can even create a service (without interface) and let it execute separately from your main application.
For another platform, I don't know the answer.

On iOS you can set a web page to run as a web app. There is even an SO tag for iphone standalone web apps, and the overview explains it nicely.
Here is the equivalent for Android - Add to homescreen

Related

Opening a closed application based on events from network

this is my issue:I am developing an emergency app where real time data is important, I have a backend running socket.io, and the client is an android device. Every time the backend emits a new emergency, it should be displayed for the client if the app is opened, or renders the activity (opens the application) if it's closed.
From what I read in socket.io: Socket.IO is not meant to be used as a background service for mobile applications.(source).
And even if I try it, there are a lot of restriction that can make the app not work as needed (exp: time delay…)
My question, is there a way in Android to open/run the application based on events coming from network?
cordially,

how to make an app that automate rideshare/restaurants app requests (ex. mystro)

does anyone have any idea how to make an app that automates and filter rideshare/restaurant apps requests? It's kinda working as an umbrella for more than one app.
for example, the XYZ app will be in the foreground and will monitor both Uber Eats and Postmate in the background and whenever requests are received it will show on the XYZ app screen with its details.
I believe it's not doable on the IOS but its existing on android on an app called Mystor. it uses somehow advisability functions in the phone but I want to understand the logic behind it and know how does it work?

Android use of mobile data when in background

I have developed a hybrid app running on Android, that successfully monitors the users location and displays it to the user as a moving icon on a map. This part of the app is all written in javascript and works inside a webview. The webview also communicates with my remote server to share the user's location with other users of the same app.
Up until Android Nougat this all works even when the app is backgrounded for several days. When the user returns to the app they can see where they have been with timestamps at each point. And all the other app users can see where everyone is, even if they are no actively using the app.
From Android Oreo onwards, I had to move the location tracking to a background service to get it to continue in the background and I have tested this to be still working fine even with the app in the background for a long period. Returning to the app, the user can still see where they have been. However the remote communications to the server, on Android Oreo and later, cease after approximately 2 minutes in the background.
Please could someone explain why this is, and what I could (if anything) do about it?
What is the restriction that I am running into and where is it documented on Android developer? I have set the app as not to be limited in settings/network/data saver and this makes no difference.
Would it make a difference if I replaced the webview XMLHttpRequest with similar code in background service, using volley or something similar?
All help very much appreciated.
Although I have not discovered what restriction I am running foul of, I have found that by moving the http request from the web view to the background service using volley, the server continues to be updated whether or not the application is in the foreground.
Only tested so far on Android 8,9 and 10 in the emulator. Testing soon on a real device

Is there a way to retrieve the current foreground application in Flutter (while app is running in background)?

I am looking to have my Android (Flutter) application running in the background, checking what app is currently running in the foreground.
When a certain app is opened (eg: Snapchat), I would like to redirect the user BACK to my application.
I've seen native android code that can accomplish this, but I was wondering if there were any Flutter-specific plugins that can accomplish this goal?
I'm aware that you can grab a list of currently installed applications using Flutter, but is there a way to see which app is running in the foreground and then redirect back to my own application, or is this something that would have to be done natively?

How to have an android phonegap app allways running

I have an Android app (internal for my company, not public) developed using JQM and Phonegap.
The app check each 15 minutes if the company server have some news for the device (1 device = an employee).
But it only works if the device is not in sleep mode.
I would like at least be able to do the same as whatsapp and other apps, send a little message to the notification area and/or shows a little window, sounds a beep...
I can do some of this (as shows a window, sounds a beep) but only if the device is running in visible (not sleep) mode.
Then my question is:
How to have an android phonegap app that is always running, or at least run each x minutes?
I this is not possible... Is possible then create an "mini" real native app only for this purpose, thus "call" to my app each x minutes?
Thanks,
Guillermo, Spain.
link http://www.tipsfromsiliconvalley.com/2013/07/06/create-a-service-on-android-with-phonegap-application/
There is this article on how to create a service on Android with Phonegap which gives some good information on your problem.
It's using a great plugin in order to build a background service with phonegap easily. But you can't use JS though
I didn't find a way to make JS to run in the Background. BUT you can pass parameters from Java to JS and vice versa with the plugin...which is pretty useful. You would still need to rewrite your JS code in Java though.
you could create a service that calls a javascript callback? For example, you could have a service in Java code that when it receives a text message it calls a javascript callback function to execute some JS code? That would be perfect. plugin that seems to create a service and call Js code:
https://github.com/marknutter/GCM-Cordova

Categories

Resources