Progress Dialog showing when Back Ground Task Running in Android

package com.raja.vedioapp;

import android.app.Activity;
import android.app.ProgressDialog;
import android.os.AsyncTask;
import android.os.Bundle;

public class MainActivity extends Activity {

@Override
protected void onCreate(Bundle savedInstanceState)

{
super.onCreate(savedInstanceState);
setContentView(R.layout.activity_main);
new BackGround().execute(“hi”);
}
class BackGround extends AsyncTask<String, Void, String>
{
ProgressDialog progress;
@Override
protected String doInBackground(String… params)
{
for(int i=0;i<=10000;i++)
{
System.out.println(“Background Task “+i);
}
return “success”;
}

@Override
protected void onPostExecute(String result)
{
System.out.println(“BackGround Task Completed Result is “+result);
progress.cancel();
}

@Override
protected void onPreExecute()
{
progress=ProgressDialog.show(MainActivity.this, “Progress”, “Please Wait…”,true);
}

}
}

Advertisements

One thought on “Progress Dialog showing when Back Ground Task Running in Android

  1. 2006 March 30, 2013 at 12:28 pm Reply

    Hey There. I discovered your blog site making use of msn. This is an exceptionally well composed guide. I will make sure to bookmark it and come back to review more of your helpful information. Thanks for the post. I’ll definitely return.

Leave a Reply

Fill in your details below or click an icon to log in:

WordPress.com Logo

You are commenting using your WordPress.com account. Log Out / Change )

Twitter picture

You are commenting using your Twitter account. Log Out / Change )

Facebook photo

You are commenting using your Facebook account. Log Out / Change )

Google+ photo

You are commenting using your Google+ account. Log Out / Change )

Connecting to %s

%d bloggers like this: