tags:

views:

33

answers:

2

-->I am new to Android And i want to show two progress dialog one after another??

-->First i want to show when my image is load from internet, when this process is done i have set A button on that Remote image.

-->When i click that button i want Dialog for second time..(on clicking button i have set video streaming code.. before video is start i want to close that Dialog..)

Any Help???? Thanks...

A: 

You can create 2 threads. First for image when it is loaded then call another thread of video. Make two runnable actions and two handlers to handle that

public void onCreate(Bundle savedInstanceState) {
    ProgressDialog pd = ProgressDialog.show(this, "","Please Wait", true, false);

    Thread th = new Thread(setImage);
    th.start();

}

public Runnable setImage = new Runnable() {
    public void run() {
        //your code 
        handler.sendEmptyMessage(0);
    }
};

private Handler handler = new Handler() {
    @Override
    public void handleMessage(Message msg) {

        if (pd != null)
            pd.dismiss();
    }
};
krunal shah
is it possible to create two Thread within one class??
phk101
ya. it is possible. For video you make one and for image one
krunal shah
A: 

On Android it's best to use AsyncTask to execute tasks in the background while still updating UI:

  1. Extend the AsyncTask
  2. Start the progress dialog in onPreExecute()
  3. Define the background task in doInBackground(Params...)
  4. Define updating of the progress dialog in onProgressUpdate(Progress...)
  5. Update dialog by calling publishProgress() from doInBackground()
  6. Start a new Dialog #2 in onPostExecute().
Peter Knego