0

I'm currently trying to remake our company app that has been outsourced. We do not have access to the source code so its not possible to look at the code. Our outsourced app has a service running in the foreground with a notification. When the outsourced app is closed by the user in the open app list (I'm unsure what it's called) it doesnt really close. Its behavior is almost like it's being minimized. When opening the outsourced app after closing it opens immediately right where it was last left off like it was never closed. Not even a splash screen. It's behavior is like its being resumed.

I've been able to run a foreground service with binding and unbinding following the sample ForegroundLocationTracking embarcadero has given. The app stays open despite the user going to the home screen or locking the phone. The problem comes when the app gets terminated by the user from the open apps list. The app is now terminated and the service briefly gets terminated but gets started by the system again.

My thoughts are that the outsourced app is running a remote service however I'm unsure.

How can I make the app have the same behavior as the outsourced app? The service will keep running in the foreground. No briefly terminating and starting again. The main app must also just resume like the outsourced one does or have the same behaviour.

Adriaan
  • 806
  • 7
  • 24
  • Where is the "ForegroundLocationTracking" sample you're referring to? – Dave Nottage Mar 15 '22 at 10:20
  • 1
    It's located in `C:\Users\Public\Documents\Embarcadero\Studio\22.0\Samples\Object Pascal\Multi-Device Samples\Device Sensors and Services\Foreground Location Tracking` – Adriaan Mar 15 '22 at 10:49
  • Can you provide the steps to reproduce the behaviour? I've tried the sample and the service stays running for me. I'm using a device with Android 12 – Dave Nottage Mar 15 '22 at 12:07
  • The service stays running yes but when you close the app from the app list by swiping up to see your current open apps and swiping to close that app the service quickly terminates and restarts again. The main app is then terminated and doesnt produce the same behavior as the outsourced app that I mention. The steps are to open the app. Press start and close the app. Not just go to the home screen but also close it from the open app list. – Adriaan Mar 15 '22 at 12:17
  • Take a look at the Location in use icon while closing the app and watch the service restart – Adriaan Mar 15 '22 at 13:08
  • "..the service quickly terminates and restarts again." The service does not stop at all for me – Dave Nottage Mar 16 '22 at 21:03
  • Thats strange. I unfortunately only have access to a P30 Lite and a P40 Lite. Both phone have the same behavior with the sample app. Do you think it could be the to do with the phones? – Adriaan Mar 17 '22 at 07:29
  • It might be related to the version of Android, I guess? Mine has Android 12 – Dave Nottage Mar 18 '22 at 11:15
  • You can put the `Service` in a separate OS process. This should prevent the `Service` from being killed and restarted when the user swipes the app from the "recent tasks" list. – David Wasser Mar 28 '22 at 09:45

0 Answers0