Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Easy way to detect where ui thread is stalling on Android?

I have taken over an Android project from a past employee and am wondering if there is an easy tool to use for profiling an Android application. I have a LinearLayout with a ProgressBar spinner inside of it. Now I am running a network call on a different thread while that spinner is showing. I use a translate animation to show the entire LinearLayout and when the network call returns on the other thread I hide the LinearLayout. Now this works great but I see that the spinner kind of stops spinning while it is showing. Now it kind of looks like if I interact with the screen, such as trying to scroll, the spinner will continue to spin. For a standard ProgressBar spinner do I need to set some command on the spinner to keep it spinning? Any information on this would be great.

Thanks

like image 586
Bobbake4 Avatar asked Oct 26 '11 14:10

Bobbake4


People also ask

How do I know if an Android thread is running?

Assuming that rt is a Thread , just check rt. isAlive() . Alternatively, just use a boolean flag and set it to true right before you start your thread.

Which thread sometimes called the UI thread is responsible for updating the screen in an Android app?

When the user launches your app, Android creates a new Linux process along with an execution thread. This main thread, also known as the UI thread, is responsible for everything that happens onscreen. Understanding how it works can help you design your app to use the main thread for the best possible performance.


1 Answers

You could use StrictMode to detect expensive calls that are being done on the UI Thread.

like image 182
Maria Neumayer Avatar answered Oct 08 '22 02:10

Maria Neumayer