Android Question Starter service, services and activity

GDO

Member
Licensed User
Longtime User
Question 1:
1 activity : MAIN
and
1 service : SERVICE1 (running every x seconds)

I want MAIN to launch SERVICE1 :

StopService(SERVICE1) in MAIN, Activity_Pause
StartService(SERVICE1) in MAIN, Activity_Resume
and
StartServiceAt(x...) in SERVICE1, Service_Start
StopService("") in SERVICE1, Service_Destroy

is it right ?
 
Last edited:

GDO

Member
Licensed User
Longtime User
Question 2:

Same as question 1
BUT I want MAIN to start automatically :

Add 1 service renamed Starter : STARTER

#StartAtBoot: True in STARTER
StartActivity(MAIN) in STARTER, Service_Start
StopService(Me) in STARTER, Service_Start

is it right ?
 
Upvote 0

GDO

Member
Licensed User
Longtime User
Question 3: (last one)

Same as question 2

1 more service : SERVICE2

BUT I want STARTER to choose and run MAIN or SERVICE2 :

#StartAtBoot: True in STARTER
Test MAIN or SERVICE2 in STARTER, Service_Start
if test MAIN StartActivity(MAIN) in STARTER, Service_Start
if test SERVICE2 StartService(SERVICE2) in STARTER, Service_Start
StopService(Me) in STARTER, Service_Start

is it right ?

Thank you for your help.
 
Upvote 0

GDO

Member
Licensed User
Longtime User
You shouldn't set StartAtBoot: True in the starter service. Use a different service for that (the starter service will be started before it).

There is no need to call StopService.

Use a Timer if you want to run something every few seconds.

I don't understand, sorry.

Do you mean :

Create a service SERVICE3 with StartAtBoot: True and nothing more inside (and StartAtBoot: False in STARTER) ?

No StopService(Me) and no StopService("") in SERVICE1, Service_Destroy ?

Is a timer Ok every 5 ou 10 seconds ? When to use a service ?

Thanks.
 
Upvote 0

Erel

B4X founder
Staff member
Licensed User
Longtime User
  • Like
Reactions: GDO
Upvote 0
Top