Android Question App with three services

Rusty

Well-Known Member
Licensed User
Longtime User
I have an app with three services:
1. Starter - just initializes
2. Samsung Health monitor - watches the steps, calories etc. (If SHealth is installed)
3. TCP/IP communicator that reports status to a cloud/local server

On an Asus 10 inch tablet, OS version 4.4.2 or even on newer ones, the Starter service starts; the MAIN creates and resumes, where the SHealth service is started ONLY if SHealth is installed (which it is not); then regardless of anything, the TCP/IP service is started.

Strangely, only the SHealth service runs (after the Starter and MAIN); the TCP/IP service will only start during a fresh compile. The TCP/IP service is START AT BOOT as is the Starter Service, the SHealth is not set to start at boot, but even though it is NOT called via a StartService, StartServiceAt etc., it runs and the TCP service does not run.

Is it ok to have three services in the same program? Should the all, some or none be set to Start at boot?
Even though the SHealth service isn't supposed to run, it does and when I start the TCP service from within the SHealth service, it says it starts but the first line in the start code is a LOG and that log doesn't appear.

Additionally, when the tablet is powered down and back up, the Starter starts, the SHealth starts (and shouldn't) and the TCP/IP service says it starts but the log message does not appear.

Any ideas on this will be appreciated.
Regards,
Rusty
 
Last edited:

DonManfred

Expert
Licensed User
Longtime User
The TCP/IP service is START AT BOOT as is the Starter Service
you have set start at boot in the starter service?
 
Upvote 0

Rusty

Well-Known Member
Licensed User
Longtime User
Yes, both Starter and the TCP service are Start at boot.
Is this correct? Or should only one be set to Start at boot? If so, which one?
Thanks Don.
 
Upvote 0

nobbi59

Active Member
Licensed User
Longtime User
Set Start at Boot for the Shealth Service that calls/triggers your TCP/IP Service. Otherwise TCP/IP Service will be started, no matter if SHealth is installed or not.
 
Upvote 0

Rusty

Well-Known Member
Licensed User
Longtime User
Thanks!
I removed the Start at Boot from the Starter, left it in the TCP service.
I UNINSTALLED THE APP/SERVICES and recompiled. (I had not uninstalled so I am assuming the services were still running from previous runs.)
Re-Compiled/installed
Re-booted the tablet
All looks good now :) !!!
Thanks to all who helped.
Rusty
 
Upvote 0

Rusty

Well-Known Member
Licensed User
Longtime User
Is there a way to programmatically uninstall my app prior to reinstalling it (including the services)?
The thought is that since I have to stop a service in my deployed tablet base and (re) install the app to cause the proper service to begin running, I will need to manage this when I deploy the new version of the app with the corrections from above.
Any thoughts?
Thanks,
Rusty
 
Upvote 0

Rusty

Well-Known Member
Licensed User
Longtime User
Would the services (previously installed with the old version) be stopped if I placed this code at the top of the Starter service in my NEW code?
B4X:
Sub Service_Create
    Fn.MyLog("Create...")
    Try
        StopService(svcTSComms)
        StopService(svcSHealth)
    Catch
        Fn.myLog("Starter Create error: " & LastException)
    End Try
     ...
 
Upvote 0
Top