Android Question Avoiding Delay in GUI when running background services

Marcos Alves

Well-Known Member
Licensed User
Longtime User
I have one app that , when starting at the first time, needs to do many requests to a remote server to eventually upgrade some parameters and data in user interface (even in some resumes this requests are also interesting to avoid the needing of finishing the activity to refresh data)...
I noticed some freezing when opening the activity due these background services and think that it's something related to the time between httputils post requests and answers... the gui doesn't depends on the results of services. There is a local database and the background services will only update this database (and request a callsub, if the respective activity is not paused).
But the user experience is a little bit compromised with the "small freezing events"... Is this happening because the httpjob runs in the same thread? If yes, is there any workaround?
 

Marcos Alves

Well-Known Member
Licensed User
Longtime User
You should only test performance on a real device running in release mode.
Hi @Erel . Yes, in real devices the performance is pretty good... I think that my users can live with this as in real devices I notice only very small 0,1 - 0,2 sec delays... thanks!
 
Upvote 0

Marcos Alves

Well-Known Member
Licensed User
Longtime User
Hi Marcos, i have been using the thread library for a while and i haven't had any issues with it so far, the reason i started using it is because i made an app for a client that required creating a pdf workbook of more than 300 pages, as you can imagine this process takes a long time to complete depending on the amount of information each pdf page contains, if I left the application run without any type of background task handling then the user would just keep tapping on the screen now knowing whether the application crashed, then the OS would keep popping up the message saying wait or close application.

I know Erel doesn't recommend using this library and I understand his reasoning behind it, but i personally have not had any issues with it, the only downside of it is that you won't be able to run your up in debug mode.

Regards,
Walter
thanks @walterf25 . I'm more comfortable with you success case description. You know, in "Android Babel tower" deprecating problems are a constant concern. Working with threads is really very hard and sometimes unpredictable , but if we take care about maintaining a healthy dependence of the data generated from them - guarantying that the main program/gui would no crash without this data and always designing a good main program flow - , we will not have problems. I worked a lot with threads in industrial machines and real time systems and they are indispensable to maintain a good user experience and the systems assurance and stability.
 
Upvote 0
Top