2

Possible Duplicate:
Android ASync task ProgressDialog isn't showing until background thread finishes

I am implementating an android app. I have following Activity 1.StartMenu:-In This Activity there is three button when i press Start. it moves on Another Activity AndroidGame. in Androidgame There is context of Main game panel.so it start executing game. I want that when maingamepanel loads it show a progressDilog .after selecting yes it should start game.I am unable to progress dialog. please suggest where should progressDialog kept? AlertDialog.Builder alertDialogBuilder = new AlertDialog.Builder( this);

    // set title
    alertDialogBuilder.setTitle("Your Trial Period has Expired.");

    // set dialog message
    alertDialogBuilder.setCancelable(false).setPositiveButton("Ok",
            new DialogInterface.OnClickListener() {
                public void onClick(DialogInterface dialog, int id) {



                }
            });

    // create alert dialog
    AlertDialog alertDialog = alertDialogBuilder.create();

    // show it
    alertDialog.show();
Community
  • 1
  • 1
user1602798
  • 365
  • 3
  • 5
  • 13

1 Answers1

0

After Clicking the button in alert dialog it starts another activity. There in onCreate() method write the following:

    doback dob=new doback();
    dob.execute();

below the oncreate()

    class doback extends AsyncTask<URL, Integer, Long>
 {

  protected Long doInBackground(URL... arg0) 
  {

  }
  protected void onProgressUpdate(Integer... progress) 
  {

  }
  protected void onPostExecute(Long result) 
  {
   try
   {
    dialog.dismiss();
   }
   catch(Exception e)
   {
    e.printStackTrace();
    dialog.dismiss();
   }
  }
 }
Santosh
  • 611
  • 2
  • 6
  • 24