Using ProgressDialog in android application startup
How can I show a progressDialog during the start up of an application. I have shown a progressDialog in the oncreate method and its not showing when launching the application.
I have gone through this: ProgressDialog not showing until after function finishes
I have tried the solution explained for the above question. But its not working perfectly.
Here is my code:
public void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
setContentView(R.layout.dash);
progressDialog = ProgressDialog.show(this, "", "Loading...");
//Run background UI thread
Thread laucherThread = new Thread(new Runnable() {
public void run() {
Looper.prepare(); //I had to include this to prevent force cl开发者_运维知识库ose error
startService(new Intent(DroidChirp.this,ChirpService.class));
doBindService();
Log.e(MY_DEBUG_TAG, "Prepairing to close the dialog");
runOnUiThread(new Runnable() {
public void run() {
progressDialog.dismiss();
}
});
Log.e(MY_DEBUG_TAG, "Closed the dialog");
}
});
laucherThread.start();
}
What I need to do is:
- Show a progressDialog until all the initial setup is finished
Issues I am facing :
- ProgressDialog is not showing at the start up.
- There is a delay when starting the application(Showing blank for sometime).
- ProgressDialog appears just before finishing the initial setup.
Can anyone suggest me how can I establish this feature. Its a tablelayout with list view for each tab.
If you want to show a progress dialog, while fetching data or something like this, you need to use AsyncTask
with ProgressDialog
bounded. See an example here.
精彩评论