Reputation: 1115
I would like to know whether it is a good practice to write for loop that loops around 400-500 times inside android main thread or should i go for an another thread. Thanks in advance.
Upvotes: 0
Views: 221
Reputation: 42450
Since you say the loop is processing several hundred coordinates, it should definitely be an AsyncTask
or a background thread. Even if the user cannot interact with the UI in that period, this will allow you to show a spinner or dialog for that duration. Further, if the UI thread is unresponsive for more than a certain amount of time, the OS considers the app to have crashed, and gives the user the 'This app has stopped responding' dialog box.
Upvotes: 1