Difference between revisions of "Progress Dialog and Threads"
From John Freier
(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 | |
| − | + | 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() | |
| − | dialog = ProgressDialog.show(CurrentActivity.this, "","Posting to twitter...", true); | + | { |
| − | + | 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(); | |
| − | + | ||
| − | + | ||
| − | + | ||
| − | + | ||
| − | + | ||
| − | + | ||
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();