Android Question CallSubDelayed

b4auser1

Well-Known Member
Licensed User
Longtime User
I have read in the manual: Tutorial - Using CallSubDelayed to interact between activities and services

CallSubDelayed makes it much simpler. It allows you to call a sub in a different service or activity. If the target module is not active, then it will be started automatically. When the target module is ready, the sub will be called.

CallSubDelayed doesn't immediately call the target sub. It sends a message to the message queue. The internal framework manages this message and passes it to the target module when it is ready.

----------

But my experments showed, that CallSubDelayed called from service doesn't force the activity, which is not active, to be started automatically. Is it correct behavior ?
 

thedesolatesoul

Expert
Licensed User
Longtime User
Yes, this is the correct behaviour.

I'm not sure what kind of selective reading you are doing, the answer to your question is on the same page just a few lines below:

- If the target module is an activity:
- If the application is visible (one of its activities is visible) then the target module will be started if needed and the sub will be called.
- If the application is in the background (can happen when a service calls an activity) then the message will be stored in a special message queue. In this case the sub will be called when the target activity becomes visible. The sub will be called before Activity_Resume.
 
Upvote 0
Top