title: AdvertisingIdClient getAdvertisingIdInfo blocked by main thread
body: <p>I'm trying to wait the response of AdvertisingIdClient.getAdvertisingIdInfo(activity) without success. This method never response until the main thread has finished.</p>
  
  <pre class="lang-java prettyprint-override"><code>import android.app.Activity;
  import android.os.Bundle;
  import android.os.SystemClock;
  import android.util.Log;
  import com.google.android.gms.ads.identifier.AdvertisingIdClient;
  import com.google.android.gms.common.ConnectionResult;
  import com.google.android.gms.common.GooglePlayServicesNotAvailableException;
  import com.google.android.gms.common.GooglePlayServicesUtil;
  import java.io.IOException;
  
  
  public class MyActivity extends Activity {
  
      private Activity m_activity = null;
      private AdvertisingIdClient.Info m_info = null;
  
  
      @Override
      public void onCreate(Bundle savedInstanceState) {
          super.onCreate(savedInstanceState);
          setContentView(R.layout.main);
  
          // start the thread with the getAdvertisingIdInfo()
          startGoogleAdvertisingIdRequest(this);
  
          // simulate a waiting loop, others app init, ...
          for (int i=0; i&lt;20; i++) {
              SystemClock.sleep(100);
          }
  
          // get the uuid
          String uuid = getGoogleAdvertisingId();
  
          // call a method who need the uuid
          Log.i("UUID", "receive uuid: " + uuid);
      }
  
  
      public String getGoogleAdvertisingId() {
          String uuid = null;
          if (m_info != null) {
              if (!m_info.isLimitAdTrackingEnabled()) {
                  uuid = m_info.getId();
              } else {
                  uuid = "another uuid";
              }
          } else {
              uuid = "another uuid";
          }
  
          return uuid;
      }
  
      public void startGoogleAdvertisingIdRequest(final Activity activity) {
          m_activity = activity;
          if (GooglePlayServicesUtil.isGooglePlayServicesAvailable(activity) == ConnectionResult.SUCCESS) {
              new Thread(new Runnable() {
                  @Override
                  public void run() {
                      AdvertisingIdClient.Info adInfo = null;
                      try {
                          Log.i("UUID", "before google request");
                          adInfo = AdvertisingIdClient.getAdvertisingIdInfo(activity);
                          Log.i("UUID", "after google request");
                      } catch (IOException e) {
                          Log.w("UUID", "getAdvertisingIdInfo IOException: " + e.getMessage());
                      } catch (GooglePlayServicesNotAvailableException e) {
                          Log.w("UUID", "GooglePlayServicesNotAvailableException: " + e.getMessage());
                      } catch (Exception e) {
                          Log.w("UUID", "GooglePlayServicesException: " + e.getMessage());
                      } finally {
                          finished(adInfo);
                      }
                  }
              }).start();
          }
      }
  
      private void finished(final AdvertisingIdClient.Info adInfo){
          if(adInfo != null){
              m_activity.runOnUiThread(new Runnable() {
                  @Override
                  public void run() {
                      m_info = adInfo;
                      Log.i("UUID", "runOnUiThread id: " + adInfo.getId());
                  }
              });
          }
      }
  }
  </code></pre>
  
  <p>Logcat of this code</p>
  
  <pre class="lang-bash prettyprint-override"><code>11:29:52.103  30810-30828/com.example.testuuid I/UUID﹕ before google request
  11:29:54.107  30810-30810/com.example.testuuid I/UUID﹕ receive uuid: another uuid
  11:29:54.127  30810-30828/com.example.testuuid I/UUID﹕ after google request
  11:29:54.151  30810-30810/com.example.testuuid I/UUID﹕ runOnUiThread id: d5dc3bfb-4756-490c-8f8e-2bedfb5e827a
  </code></pre>
  
  <p>Same logcat with more waiting time (5s)</p>
  
  <pre class="lang-bash prettyprint-override"><code>11:36:14.215  31413-31436/com.example.testuuid I/UUID﹕ before google request
  11:36:19.225  31413-31413/com.example.testuuid I/UUID﹕ receive uuid: another uuid
  11:36:19.293  31413-31436/com.example.testuuid I/UUID﹕ after google request
  11:36:19.315  31413-31413/com.example.testuuid I/UUID﹕ runOnUiThread id: d5dc3bfb-4756-490c-8f8e-2bedfb5e827a
  </code></pre>
  
  <p>Each time the getAdvertisingIdInfo(), who is in another thread, is blocked by the main thread.</p>
  
  <p>What is the reason ? and how to do this ?</p>