Android Question How can I know the names of services started by... my app

LucaMs

Expert
Licensed User
Longtime User
If I create and start a service I know its name, of course, but some library added to my project may start a service: is there a way to get a list of services started by my app?


Thank you
 
Last edited:

LucaMs

Expert
Licensed User
Longtime User
I guess that the library doesn't start one of your services, right?
Rigth. I mean: if a library starts its own service.

What do you need it for?
To close "completely" my apps; I think I have to close all my activities using Activity.Finish, stop all services and use ExitApplication, but I need to know if there are services started by the libraries I use, to be able to stop them.
 
Upvote 0

LucaMs

Expert
Licensed User
Longtime User
You don't need to do it. Let the OS decide when to kill the process. It will happen at some point when your app is in the background.

I know but if you don't close "well" your app, as you know it may be restarted from the wrong Activity (this is why you created the Starter service).
Also, some FirstTime may be result set to False (but I think that Activity.Finish should be enough for this).

However, your answer:
I don't see any simple way to see which services are running

is what I feared


Thank you, Erel
 
Upvote 0

Erel

B4X founder
Staff member
Licensed User
Longtime User
as you know it may be restarted from the wrong Activity (this is why you created the Starter service).
This is not 100% accurate. Services will never affect which activity will start. The app is allowed to start from a different activity. For example if the user presses on the home button when Activity2 is in the foreground and later returns to your app (after the process was killed).
If you initialize all the process global variables in the starter service then everything will work as expected.
 
Upvote 0

LucaMs

Expert
Licensed User
Longtime User
Yes, I explained badly what I mean, but you have understood anyway.

Thank you
 
Upvote 0
Cookies are required to use this site. You must accept them to continue using the site. Learn more…