title: Synchronous startActivityForResult - Waiting for Activity to Complete
body: <p>I have an application where I am launching a new Activity, and need to have the result of the activity before proceeding.</p>
  
  <p>I realize that startActivityForResult is asynchronous / non-blocking, and that I can get the result of the activity in the onActivityResult callback. </p>
  
  <p>So I guess what I'm looking for is the best way to wait for the activity to return...
  Something like this perhaps? Or is there a better way?</p>
  
  <p>Activity Launcher Function:</p>
  
  <pre><code>public String ActivityLauncher()
  {
     //Set up Intent
     startActivityForResult(intent, 1);
     while (mIsActivityDone == false)
     {
         Thread.Sleep(250);
     }
     //Continue with processing
     String data = "&lt;Data from Activity"&gt;
     return data;
  }
  </code></pre>
  
  <p>Callback:</p>
  
  <pre><code>protected void onActivityResult(int requestCode, int resultCode, Intent data)
  {
     //Pull out the data
     mIsActivityDone = true;
  }
  </code></pre>
  
  <p>The data needs to be returned to a higher level calling function - this is why I need to wait for the result in the ActivityLauncher function.</p>
  
  <p>Thanks!</p>