I am new to Android development and am facing a slight issue. My first screen is a basic log in screen. There is a LOG IN button on the screen and a OnClickHandler implemented for the button.
When the user clicks the log in button i validate the user name and password, shows a ProgressBar dialog start a new Thread. The thread connects to the server and validates the user info. The problem is that the Progress Bar doesn’t show until after the thread has finished. I read that all work must be done in a separate thread otherwise the Progress Bar will not see the light of day and i am doing my work in a separate thread.
But the problem is that right below the thread code i have a loop while(userinfo==null){} . This is because the userinfo object is been populated by the newly created thread and the userinfo object is required by code below the thread, without the loop a new thread would be created that fills the userinfo object but in the mean time the code that reads the userinfo would get a null object. If any one is willing to review the code i could send the file that has this code. Really need some help in this.
You might find AsyncTask helpful. Do whatever it is you do in the loop in postexecute instead.