Android Question Avoid App Stop - High Priority Services

Marcos Alves

Well-Known Member
Licensed User
Longtime User
Hello all,

we have an app for business messages that must to be always active. To avoid maintaining the service in foreground, we use Firebase Cloud Messages to start it when a server event is generated, what sends a FCM to Android and then runs the message receiving routine.
I noticed that rarely we have some errors (natural from an asynchronous process receiving complex data from internet), those stop the app. In this situations, if the user doesn't restarts manually it stops to receive messages (FCM routine doesn't receive push events anymore).
Is there some way, without using a Foreground Service with icon, to garante that the app will continue to receive Firebase Cloud Messages and start, even after an error (like in old versions of android where it was possible to configure a service that where automatically restarted by system)?
I notice that, after an error, if the user doesn't restart the app, even ServiceStartAt doesn't work...
 

OliverA

Expert
Licensed User
Longtime User
The code I posted here (https://www.b4x.com/android/forum/threads/auto-restart-an-android-application-after-a-crash.103858/) also works inside a Service (with some slight modifications). With it, the service stops without user intervention and is available for the next intent (tested). @Erel suggested using Application_Error and I'll test that once I receive a clarification about Application_Error processing (see https://www.b4x.com/android/forum/t...application-after-a-crash.103858/#post-652597).
 
Upvote 0

Marcos Alves

Well-Known Member
Licensed User
Longtime User
The code I posted here (https://www.b4x.com/android/forum/threads/auto-restart-an-android-application-after-a-crash.103858/) also works inside a Service (with some slight modifications). With it, the service stops without user intervention and is available for the next intent (tested). @Erel suggested using Application_Error and I'll test that once I receive a clarification about Application_Error processing (see https://www.b4x.com/android/forum/t...application-after-a-crash.103858/#post-652597).
Hello,

After some experiences, I developed a solution with:

- Application_Error (starter service)
- Send to a remote server the error log (using http service)
- Continue silently (or manage silently the error, using also the server analysis feedback when possible)

It's working fine and I'm creating an error_log table in our server... in the next weeks, with some time, I'll post a code snippet with an app and server side samples...

Thanks for all and specially for you @OliverA
 
Upvote 0
Top