Advertisement
cyberrogg

Android Thread ProgressDialog Error

Jun 14th, 2011
110
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Java 0.70 KB | None | 0 0
  1. public class UpdateDBProgressDialog extends Activity implements Runnable {
  2.    
  3.     private TextView tv;
  4.     private ProgressDialog pd;
  5.     private RatedCallsService rcs = new RatedCallsService();
  6.  
  7.     @Override
  8.     public void onCreate(Bundle icicle) {
  9.         super.onCreate(icicle);
  10.         setContentView(R.layout.main);
  11.         pd = ProgressDialog.show(this, "Updating Database", "The application is updating the database. Please wait.", true, false);
  12.         Thread thread = new Thread(this);
  13.         thread.start();    
  14.     }
  15.    
  16.     public void run() {
  17.         rcs.updateDB();
  18.         handler.sendEmptyMessage(0);           
  19.     }
  20.    
  21.     private Handler handler = new Handler() {
  22.         @Override
  23.         public void handleMessage(Message msg) {
  24.             pd.dismiss();      
  25.         }
  26.     };
  27. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement