Android Question HttpJob and Activity_Pause event

Alex_197

Well-Known Member
Licensed User
Longtime User
I have a HttpJob that will consume a webservice.

How the "HttpJob" will behave if the user clicks on a home button?

Is it possible for HttpJob to continue woring while the app is in background?

Thanks.
 

Alex_197

Well-Known Member
Licensed User
Longtime User
Switch to B4XPages and don't worry about such hurdles.
I'm new in B4XPages. Please correct me if I wrong - I started the sync with my webservice. Before the sync finishes the user clicks on Home button and the Activity_Pause event fired. The app goes into background and the sync stops. Or am I wrong?
 
Upvote 0

JohnC

Expert
Licensed User
Longtime User
Why not make the sync service be a foreground service, so when the sync starts, you will see a notifiction (maybe something like "Syncing...") in the status bar even if the user clicks the home button.

Then when the sync service is done, it terminates and the notification goes away.
 
Upvote 0

Alex_197

Well-Known Member
Licensed User
Longtime User
Why not make the sync service be a foreground service, so when the sync starts, you will see a notifiction (maybe something like "Syncing...") in the status bar even if the user clicks the home button.

Then when the sync service is done, it terminates and the notification goes away.
Thank you for the advice. Will it work only with B4XPages or not? I don't have time now to rewrite the whole app to B4XPages. Also - will it work with Android 13?
 
Upvote 0

JohnC

Expert
Licensed User
Longtime User
Thank you for the advice. Will it work only with B4XPages or not? I don't have time now to rewrite the whole app to B4XPages. Also - will it work with Android 13?
My suggestion should work with non-B4Xpages app.
 
Upvote 0

Erel

B4X founder
Staff member
Licensed User
Longtime User
The app goes into background and the sync stops. Or am I wrong?
1. In B4XPages the app will not be paused and nothing special is needed. It is true that the OS can kill the process but it will not happen immediately.
2. In non-B4XPages the recommended way is to make the request from the starter service. The reason that I suggest switching to B4XPages is that it makes such things (as well as many others) much much simpler.
 
Upvote 0
Top