Android Question Start the activity while the app in background

Alex_197

Well-Known Member
Licensed User
Longtime User
Hi all.

My app consumes a webservice and I'm using HTTPJob in foreground service.

Based on the results given by this webservice I need to start different activities.

For example if user's account has problems - start activity ProviderProblems, if all is Ok - start activity SelectClient. It works fine even if the user clicked the Home button and the app goes into background. It doesn't interrupt the sync. But if the app in the background the new activity doesn't start.

I tried to use StartActiity - no errors, just nothing.
I tried to use CallSubDelayed("actiivityname","procname") - no errors, no exceptions, activity doesn't start and in the log I see a message "sending message to waiting queue of uninitialized activity (donothing)" where donothing is just a procedure name.

If the app in foreground all works fine.

So how to start the activity while the app in background?

The rule says

Rules
- If the target module is already running then the sub will be called.
- If the target module is a service and it is not already running then it will first be started (Service_Create and Service_Start will first be executed).
The sub will be called after Service_Start.
- 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.
I expected that when the app becomes visible the activity will be called. It's doesn't.
 

Solutions Development

Member
Licensed User
Longtime User
Try this

this method allows you to have your app always in the foreground and so you can open other Activities even when it doesn't seem visible.
 
Upvote 0
Top