I have a log-in screen that I’m using for my application. It calls JSON to verify if the username/password is correct, if so, it signs them in and they are directed to the main menu. However, since it takes about 10-15 seconds to log in, I added a very simple “Progress Bar” widget to display that it is, in fact, signing in (so the user isn’t confused). However, whenever I test it on the emulator and log in, the log-in screen seems to freeze and then after the 10-15 seconds it logs in just fine, but the Progress Bar never displayed because the AVD screen is freezing up. I have it to set itself to visible when the JSON call is made. If I go back to the log-in screen after I am logged in successfully, the progress bar is there and showing up just fine.
Any tips on a way to remedy this? Thanks guys!
I recommend you to use
AsyncTaskfor performing long-time taking operations. And to notify user useProgressBarorAlertDialogor any other notifier, which fits your needs.You should think about slow networks (2G, 3G) and possible data-rates limits, whatever, what can slow operation.
Your code should be handling long-time taking operations in another than UI thread (which is basically what
Activityis, the UI thread).To understand use and purpose of
AsyncTaskconsider reading following links.http://developer.android.com/reference/android/os/AsyncTask.html
http://developer.android.com/resources/articles/painless-threading.html
http://developer.android.com/guide/practices/design/responsiveness.html