Android Progress Dialog Example

In android, we can show progress bar through dialog also. For this we need to use ProgressDialog.

Here is a example for how to use ProgressDialog : -

[sourcecode language="java"]
public class ExampleApp extends Activity {
@Override
protected void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
setContentView(R.layout.main);
ProgressDialog dialog = ProgressDialog.show(ExampleApp.this, "",
"Please wait for few seconds...", true);
}
}
[/sourcecode]
To dismiss a ProgressDialog use ProgressDialogName.dismiss() ( ex :- dialog.dismiss()).
The output will looks like
progressdialogexample

Android Progress Dialog Style Example

Comments

Hey nycsdk, set this line in

Hey nycsdk,

set this line in onClick() to show progress dialog

ProgressDialog dialog = ProgressDialog.show(ExampleApp.this, "Heading","Please wait for few seconds...", true);

@nycsdk, you need to use

@nycsdk,
you need to use dialog.dismiss(); to close the progressdialog.

Hey nycsdk, I already

Hey nycsdk,

I already mentioned the answer in my previous comment.
http://www.androidpeople.com/android-progress-dia...

@nycsdk, Try using thread and

@nycsdk,

Try using thread and check whether the mediaplayer started playing or not in background using isPlaying() in meida player.

ex:-

if(!mPlayer.isPlaying())

{

dialog.dismiss();

// Stop the thread here after dismissing the dialog.

}

@nycsdk, You need to create

@nycsdk,

You need to create a thread. Thread will run in background process.
In thread you need to check whether the mPlaer is playing or not.
using that mPlayer.isPlaying() you need to control your dialog.