title: Android - wait for touch event
body: <p>In my Android app, I'd like to display several images on the screen in sequence, waiting for a touch event (a single tap) to go to the next one.  I saw <a href="https://stackoverflow.com/questions/5791307/wait-for-3-seconds-or-user-click">here</a> that one way to do this should be:</p>
  
  <pre><code>public class LoadImage extends Activity {
      private Thread thread; //defined inside the activity
  
      @Override
      public void onCreate(Bundle savedInstanceState) {
          super.onCreate(savedInstanceState);
  
          setContentView(R.layout.activity_load_image);
  
          [get an image and create a bitmap from it]
  
          ImageView imageView = (ImageView) findViewById(R.id.imageView);
          imageView.setImageBitmap(bitmap);
  
          thread = new Thread() {
              @Override
              public void run() {
                  try {
                      synchronized(this) {
                          wait(100000000); //large number
                      }
                  }
                  catch(InterruptedException ex) {                    
                  }         
              }
          };
          thread.start();    
     }
  
      @Override
      public boolean onTouchEvent(MotionEvent evt) {
          if (evt.getAction() == MotionEvent.ACTION_DOWN) {
              synchronized (thread) {
                  thread.notifyAll();
              }
          }
          return true;
      }
  }
  </code></pre>
  
  <p>However, this code appears to just skip the waiting and immediately jump to the last image.  What's wrong with it, and/or is there a better way to do this?</p>