title: android: hide progressdialog whe the app regain control
body: <p>I've an app that opens the facebook app when you click on a button, it works fine but on slow devices (like mine) facebook takes some seconds to show up, so i want to add a simple progressdialog that says "please wait"</p>
  
  <p>i can show the progress dialog and open facebook with this code:</p>
  
  <pre><code>final ProgressDialog pd = ProgressDialog.show(contatti.this, "", "Attendere...", true);
              Intent facebookIntent = getOpenFacebookIntent(getApplicationContext());
              startActivity(facebookIntent);
  
              //pd.dismiss();
  </code></pre>
  
  <p>the first time i tried, it worked fine but when i went back from facebook to my app the dialog was still showing, and i had no way to close it. </p>
  
  <p>added dismiss() to try hide it, but it was a stupid idea >.&lt;</p>
  
  <p>how can i dismiss the dialog when the app regain control?</p>