-1

I have create a one service which triggered every 1 minute and check at server that is there any new notification arrived or not for the user.Notification can be of 3 types which is of type text,video or image...

Now to display text notification i hve no problem,but while image/video notification is arrived i would like to show a progress dialog while it loads the data from the remote url.Once notification arrived,user clicks on a alert dialog and it redirect to the appropriate activity which can be text,image,video ..so before redirecting it i would like to show progress dialog to user .... How to do that.???? Plz help me and reply asap....

Thnx in Advance,..........

user1221162
  • 71
  • 1
  • 1
  • 6
  • 1
    use async task. You will find a tutorial on async task here: http://www.vogella.de/articles/AndroidPerformance/article.html Also do some google on async task. – asish Mar 13 '12 at 14:26

4 Answers4

0

Check this code:

  public class DialogSample extends Activity {

       private ProgressDialog progressDialog=null;

       @Override
       public void onCreate(Bundle savedInstanceState) 
       {
          super.onCreate(savedInstanceState);
          setContentView(R.layout.main);

          AsynTaskLoder asynTaskLoder=new AsynTaskLoder();
          asynTaskLoder.execute();
      }

    public class AsynTaskLoder extends AsyncTask<String,Integer,Boolean>
    {
        @Override
        protected void onPreExecute() 
        {
        progressDialog.setTitle("Please Wait");
            progressDialog.setMessage("Fetching Data...");
            progressDialog.show();
        }

    @Override
    protected Boolean doInBackground(String... params) 
    {       
        // write your code 
        //(like : image/audio/video downloading from net)

        return true;
    }
    @Override
    protected void onProgressUpdate(Integer... values) 
    {
    }

    @Override
    protected void onPostExecute(Boolean result) 
    {
        if(progressDialog.isShowing())
        {
            progressDialog.dismiss();
        }
    }
  }
}
user
  • 86,916
  • 18
  • 197
  • 190
Rajan
  • 1,069
  • 1
  • 9
  • 17
0

Use AsyncTask to download data and show progress dialog window.

to show progress dialog:

Dialog diag = ProgressDialog.show(this, "title", "message", true);

to dismiss dialog:

diag.dismiss();
waqaslam
  • 67,549
  • 16
  • 165
  • 178
0

Assuming the user clicks on the notification. The first thing you could do in code is check if the source is done downloading, if not use AlertDialog.Builder or something similar to throw up a simple dialog box with a progress widget. Once the file has finished downloading it can call dismiss() on the dialog window and allow the user to proceed normally.

Birdnado
  • 156
  • 1
  • 7
0

You can use ProgressDialog wtih Thread and Handlder Class.

Please look at to my answer here.

Community
  • 1
  • 1
Lucifer
  • 29,392
  • 25
  • 90
  • 143