Closed. This question is opinion-based. It is not currently accepting answers.
Want to improve this question? Update the question so it can be answered with facts and citations by editing this post.
Closed 4 years ago.
Improve this question
Whats the threshold to move code execution to a background thread (asynctask, services, threads etcc) in Android ?
Say if we know a task will complete in 50 milliseconds, should we offload it to background ?
What is the limit ?
The official documentation Keep your app responsive says:
Generally, 100 to 200ms is the threshold beyond which users will
perceive slowness in an application.
But it also depends on what you are doing on the screen. The screen is refresh at 60Hz (16.6ms), which can be a problem if you are playing an animation.
They also gives many advices to fix this issues on the ANR Documentation
Related
Closed. This question is opinion-based. It is not currently accepting answers.
Want to improve this question? Update the question so it can be answered with facts and citations by editing this post.
Closed 1 year ago.
Improve this question
My professor told us in the class that updating a UI element from a background task is a bad practice because it might hang our UI, I can't understand why, can someone please elaborate
Background threads are not aware of your ui state , in simple words they are not aware if your ui still exists or not , in this case if you try to update your ui from the background thread and if by any chance your ui element doen't exist at that time, your app will misbehave (unexpected behaviour) or CRASH .
So to avoid this unexpected behaviour, we only update the ui from the main/ui thread.
Closed. This question needs details or clarity. It is not currently accepting answers.
Want to improve this question? Add details and clarify the problem by editing this post.
Closed 3 years ago.
Improve this question
I’m developing some C++ Android code and I realized that my animations are happening at only 10fps on an actual low end phone.
Has anyone ever seen Choreographer limit the FPS at such a low number?
Also I am using 32bit color and the default is 16bit.
Hypothetically if the cpu were very slow it might, but this is an octacore so I’m doubting that.
Closed. This question needs to be more focused. It is not currently accepting answers.
Want to improve this question? Update the question so it focuses on one problem only by editing this post.
Closed 7 years ago.
Improve this question
To take a one-shot, there's a solution(closed). Take a screen shot programmatically
Is there any sample that takes screen shot periodically on background thread?
Basically you want to repeat the steps mentioned in that solution every X seconds?
This thread would give you a good idea on where to begin.
Closed. This question is opinion-based. It is not currently accepting answers.
Want to improve this question? Update the question so it can be answered with facts and citations by editing this post.
Closed 8 years ago.
Improve this question
Should i use AsyncTask to load and scale photos from external storage? or there is easier way to do it? Main reason why im trying to do this is becouse im getting lag when scrolling my listview. Im displaying and scaling photos using its path.
Yes.
It can be a long running task if the photo has a lot of detail. Be careful when dealing with detailed photos on Android, you can run out of memory.
Use the Async Task or Thread to process the photos, but keep the user notified at all times, with a progress bar or notification.
Closed. This question is opinion-based. It is not currently accepting answers.
Want to improve this question? Update the question so it can be answered with facts and citations by editing this post.
Closed 9 years ago.
Improve this question
Mostly we handle network things in AsyncTask(doInBackground method). I have googled many times to find the most easy and robust way to handle network things. I have also searched here to find the appropriate answer. But still I didn't.
Maximum developers(including me) like to handle this with AsyncTask. But I don't think this is the perfect way. I have faced many problems(like slow process, ANR(Application Not Responding) for this.
So I am excepting the best answer, which will help me and many developers to handle network things in a best way.