Progress Bar using ProgressDialog Tutorial

Hi developers,
Now in want to give you tutorial about progress bar
I get this tutorial from TutorialPoints
And thanks a lot to TutorialPoints

Progress bars are used to show progress of a task. For example. When you are uploading or downloading something from the internet, it is better to show the progress of download/upload to the user.
In android there is a class called ProgressDialog that allow you to create progress bar. In order to this , you need to instantiate an object of this class. Its syntax is.
ProgressDialog progress = new ProgressDialog(this);
Now you can set some properties of this dialog. Such as , its style,its text e.t.c
progress.setMessage("Downloading Music :) ");
progress.setProgressStyle(ProgressDialog.STYLE_HORIZONTAL);
progress.setIndeterminate(true);
Following is the content of the modified main activity filesrc/com.example.progressdialog/MainActivity.java.
package com.example.progressdialog;

import com.example.progressdialog.R;

import android.os.Bundle;
import android.app.Activity;
import android.app.ProgressDialog;
import android.view.Menu;
import android.view.View;

public class MainActivity extends Activity {

   private ProgressDialog progress;
   @Override
   protected void onCreate(Bundle savedInstanceState) {
      super.onCreate(savedInstanceState);
      setContentView(R.layout.activity_main);
      progress = new ProgressDialog(this);
   }


   public void open(View view){
      progress.setMessage("Downloading Music :) ");
      progress.setProgressStyle(ProgressDialog.STYLE_HORIZONTAL);
      progress.setIndeterminate(true);
      progress.show();

   final int totalProgressTime = 100;

   final Thread t = new Thread(){

   @Override
   public void run(){
 
      int jumpTime = 0;
      while(jumpTime < totalProgressTime){
         try {
            sleep(200);
            jumpTime += 5;
            progress.setProgress(jumpTime);
         } catch (InterruptedException e) {
           // TODO Auto-generated catch block
           e.printStackTrace();
         }

      }

   }
   };
   t.start();

   }
   @Override
   public boolean onCreateOptionsMenu(Menu menu) {
      // Inflate the menu; this adds items to the action bar if it is present.
      getMenuInflater().inflate(R.menu.main, menu);
      return true;
   }
}
Modify the content of res/layout/activity_main.xml to the following
<RelativeLayout xmlns:android="http://schemas.android.com/apk/res/android"
   xmlns:tools="http://schemas.android.com/tools"
   android:layout_width="match_parent"
   android:layout_height="match_parent"
   android:paddingBottom="@dimen/activity_vertical_margin"
   android:paddingLeft="@dimen/activity_horizontal_margin"
   android:paddingRight="@dimen/activity_horizontal_margin"
   android:paddingTop="@dimen/activity_vertical_margin"
   tools:context=".MainActivity" >

   <Button
      android:id="@+id/button1"
      android:layout_width="wrap_content"
      android:layout_height="wrap_content" 
      android:layout_alignParentTop="true"
      android:layout_centerHorizontal="true"
      android:layout_marginTop="150dp"
      android:onClick="open"
      android:text="@string/download_button" />

   <TextView
      android:id="@+id/textView1"
      android:layout_width="wrap_content"
      android:layout_height="wrap_content"
      android:layout_alignParentRight="true"
      android:layout_alignParentTop="true"
      android:layout_marginTop="19dp"
      android:text="@string/download_text"
      android:textAppearance="?android:attr/textAppearanceLarge" />

</RelativeLayout>

Modify the res/values/string.xml to the following
<?xml version="1.0" encoding="utf-8"?>
<resources>
   <string name="app_name">ProgressDialog</string>
   <string name="action_settings">Settings</string>
   <string name="hello_world">Hello world!</string>
   <string name="download_button">Download</string>
   <string name="download_text">Press the button to download music</string>
</resources>
This is the default AndroidManifest.xml
<?xml version="1.0" encoding="utf-8"?>
<manifest xmlns:android="http://schemas.android.com/apk/res/android"
   package="com.example.progressdialog"
   android:versionCode="1"
   android:versionName="1.0" >

   <uses-sdk
      android:minSdkVersion="8"
      android:targetSdkVersion="17" />

   <application
      android:allowBackup="true"
      android:icon="@drawable/ic_launcher"
      android:label="@string/app_name"
      android:theme="@style/AppTheme" >
      <activity
         android:name="com.example.progressdialog.MainActivity"
         android:label="@string/app_name" >
         <intent-filter>
            <action android:name="android.intent.action.MAIN" />

            <category android:name="android.intent.category.LAUNCHER" />
         </intent-filter>
      </activity>
   </application>

</manifest>

Let's try to run your ProgressDialog application. I assume you have connected your actual Android Mobile device with your computer. To run the app from Eclipse, open one of your project's activity files and click Run Eclipse Run Icon icon from the toolbar. Before starting your application, Eclipse will display following window to select an option where you want to run your Android application.
Anroid Camera Tutorial
Select your mobile device as an option and then check your mobile device which will display following screen:
Android Progress Dialog Tutorial
Just press the button to start the Progress bar. After pressing , following screen would appear
Android Progress Dialog Tutorial
It will continously update it self , and after few seconds , it would appear something like this.
And roid Progress Dialog Tutorial