title: Android sendBroadcast - waiting for BroadcastReceiver to finish
body: <p>I'm using a <code>BroadcastReceiver</code> in my Android app which simply contains the following piece of code:</p>
  
  <pre><code>public BroadcastReceiver receiver = new BroadcastReceiver() {
      @Override
      public void onReceive(Context context, Intent intent) {
          GcmIntentService.isHandled = true;
          Toast.makeText(context, "broadcast receiver test", Toast.LENGTH_SHORT).show();
      }
  }
  </code></pre>
  
  <p>I'm using this receiver to determine if my activity is running and carry out some updates in a ListView without having any notifications produced by GcmIntentService.</p>
  
  <p>With the code being simple so far, only creating a toast message, I'm unable to catch the boolean value from <code>GcmIntentService.isHandled</code> as soon as the <code>sendBroadcast</code> is invoked.</p>
  
  <p>Is it possible in any way to determine if the code for my receiver has finished running. I understand that <code>sendBroadcast</code> is an asynchronous call, and I'm making use of <code>Thread.sleep(1000)</code> so far to wait for the isHandled value, but it would be nice if there is a more reliable method on achieving this.</p>
  
  <p>Any thoughts?</p>