Opening a closed application based on events from network - android

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,

Related

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

What is the best approach to keep Android app running 24/7?

I have developed a react-native app for Android to receive real time food orders (like Uber Eats, Postmates, etc.). The app is running in a Lenovo tablet that is constantly charging. I use a GraphQL subscription to detect new orders and Firebase Cloud Notifications to check the network status of the tablet.
The problem is that right now the system eventually kills the app after some days with no interaction. I would like to know the best approach to prevent the systems kills the app and being able to run it 24/7 in this case scenario.
Thanks!
You should write a service for your app, which starts the app when it gets killed.Never ending service has a good tutorial on how to do this.

Monitor any other running app from a service Android

I was developing an app for an enterprise which has given the employees an android phone, they wanna monitor every time a user tries to open any other app and send a report to a manager so I´ve developed an android service that checks every time any other app is call meaning: OnCreate, onResume, etc.(that´s done) Now they wanna check what that particular user did once he got into the other app: for example if he opened the messages(com.android.mms) , what message he sent or what he had recieve. other example: if he opened the dialer(com.android.dialer) they wanna know what phone he called. What makes it tricky for me, is that they want this for EVERY POSSIBLE APP a user can have installed in their phone.
My Question is the following: is there a way to capture this kind of information of a running app, from a service?
I appreciate any answer and I´m open to suggestions of how should i do this.

Run mobile web application in the background as a service

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

Using sails.js to find out online status of users in Android app

I am developing an Android app that uses a Sails.js server to read and write data to a MongoDB database.
I need a method to tell whether a user is currently online or not on the app.
The definition of 'online' for my app is that the user either has logged in and has the app open on any page/activity within the last 5-10 minutes.
One method I have considered is every so often in the app running a method that updates a "lastOnline" field for the User on the server with the current timestamp, then to check whether a user is online, checking whether each user's lastOnline field is within X minutes.
Another method I have recently considered is webSockets. I am aware that Sails.js has built in Socket.io features, however I am unsure how I would be able to use them for this functionality.
The idea I had regarding sockets would involve, upon logging into the app, connect to the server using websockets. On the servers receipt of this connection, the server would change an "online" boolean field in the User model to true.
However the main question I have with this, is if the app were to close, or become inactive in the background for a few minutes, how would the server then change the online boolean to false;
Thanks for any help or advice you can offer!

Categories

Resources