Difference between revisions of "Progress Dialog and Threads"

From John Freier
Jump to: navigation, search
(Created page with ' private Handler handlerRefresh = new Handler() { @Override public void handleMessage(Message msg) { // Code to process the response and update UI. …')
 
Line 1: Line 1:
 +
private ProgressDialog dialog;
 +
 
  private Handler handlerRefresh = new Handler()
 
  private Handler handlerRefresh = new Handler()
 
  {
 
  {
    @Override
+
      @Override
    public void handleMessage(Message msg)
+
      public void handleMessage(Message msg)
    {
+
      {
          // Code to process the response and update UI.
+
          Bundle resBundle = (Bundle) msg.obj;
          Bundle resBundle = (Bundle) msg.obj;
+
          String question = resBundle.getString("key");
          String question = resBundle.getString(BUNDLE_QUESTION);
+
      }
    }
+
 
  }
 
  }
   
 
  
  
...
+
dialog = ProgressDialog.show(CurrentActivity.this, "","Posting to twitter...", true);
 
+
new Thread(new Runnable()
dialog = ProgressDialog.show(CurrentActivity.this, "","Posting to twitter...", true);
+
{
        new Thread(new Runnable()
+
      public void run()
        {
+
      {
    public void run()
+
          TwitterPost.Post(getBaseContext(), tweetString);
    {
+
    TwitterPost.Post(getBaseContext(), tweetString);
+
          Message myMessage=new Message();
   
+
          Bundle resBundle = new Bundle();
    Message myMessage=new Message();
+
          resBundle.putString(BUNDLE_USER_ANSWER, tweetString);
    Bundle resBundle = new Bundle();
+
          myMessage.obj=resBundle;
    resBundle.putString(BUNDLE_USER_ANSWER, tweetString);
+
          handlerTwitterPost.sendMessage(myMessage);
    myMessage.obj=resBundle;
+
          dialog.dismiss();
    handlerTwitterPost.sendMessage(myMessage);
+
      }
    dialog.dismiss();
+
}).start();
    }
+
        }).start();
+
 
+
...
+
 
+
private ProgressDialog dialog;
+

Revision as of 09:07, 27 January 2011

private ProgressDialog dialog;
private Handler handlerRefresh = new Handler()
{
     @Override
     public void handleMessage(Message msg)
     {
          Bundle resBundle = (Bundle) msg.obj;
          String question = resBundle.getString("key");
     }
}


dialog = ProgressDialog.show(CurrentActivity.this, "","Posting to twitter...", true);
new Thread(new Runnable()
{
     public void run()
     {
          TwitterPost.Post(getBaseContext(), tweetString);

          Message myMessage=new Message();
          Bundle resBundle = new Bundle();
          resBundle.putString(BUNDLE_USER_ANSWER, tweetString);
          myMessage.obj=resBundle;
          handlerTwitterPost.sendMessage(myMessage);
          dialog.dismiss();
     }
}).start();