Android Question The HTTP JOB is stuck in timeout and user closes the activity. JobDoneEvent (FALSE) Open the Activity again - Loop

Martin Domian

Member
Licensed User
Longtime User
I have an activity in which the user has to select something The activity loads some views via http jobs. As long as it works, everything is fine. But it can happen that the server is not accessible and the job reports an error after the set timeout (3 seconds). As long as the user does not close the activity during this time, everything is fine. But he is not that patient and presses the back button because he does not see what he is expecting. Now I can see in the log that "java.net.ConnectException: Failed to connect to" is reported, but I have no influence on that and the event JobDone comes up after(!) Activity Create and Activity Resume (again), which makes things even more difficult because code is called there that should not be started at all.
I want to prevent that, which probably only works if I call JOB.delete when Activity Pause is fired, but that means that I have to declare all JOBS global, which can't be right either.

What would be correct here or rigth programming style?
Somehow check whether jobs are still open and then somehow destroy them? Prevent an activity from closing?

Summary

What should you do if the user closes an activity while a job has not yet responded (regardless of whether it was successful or not) so that the activity is not started automatically

Thanks for good ideas
 

DonManfred

Expert
Licensed User
Longtime User
What would be correct here or rigth programming style?
Doing the httpjobs not in an Activity. Instead do them in a Service or a class initiated from a service (starter for ex).
 
Upvote 0
Top