Android Tutorial Starter Service - Consistent & Single Entry Point

Status
Not open for further replies.

Emme Developer

Well-Known Member
Licensed User
Longtime User
A simple curiosity, how this service is started before activity? Is it declared on manifest, or an event in application open for example? I ask this because i talk with a friend that works in android studio, and it uses ViewModel class to ensure a correct load of resource (that should not loaded in main activity create), but we don't have this problem because we inizialize all (where required) in staser service. This service make heavier application (in open event)? Thanks
 

Erel

B4X founder
Staff member
Licensed User
Longtime User
Is it declared on manifest
Yes.

As I wrote, under the hood the activity code starts the starter service and the code in B4A Activity_Create is called after the starter service is created.
Assuming that you are not doing too much work in Service_Create then the performance effect is minimal. You can also remove the starter service and it will not have any effect.
 

walterf25

Expert
Licensed User
Longtime User
Can the Starter service be marked as a Sticky_Service?

Do i need to call StartServiceAt or will this service keep running even if the OS decides to kill it when it needs resources?

Thanks,
Walter
 

Peter Simpson

Expert
Licensed User
Longtime User
@trueboss323 Service_Create only runs the first time the service is created and does not run again, and Service_Start is ran every time the service is called. You can test this by adding lets say log("Service_Create") to Service_Create and Log("Service_Start") to Service_Start, you can see for yourself what happens...
 
Status
Not open for further replies.
Cookies are required to use this site. You must accept them to continue using the site. Learn more…