title: Precedence of Loaders vs BroadcastReceivers started on the main thread
body: <p>Consider the following sequence of events :</p>
  
  <ol>
  <li>A <code>BroadcastReceiver</code> is registered in the <code>onResume</code> method of an <code>Activity</code> (without a handler).</li>
  <li>A <code>CursorLoader</code> is  started by calling the <code>restartLoader</code> method as the next immediate statement in <code>onResume</code> (<code>restartLoader</code> is called on the <em>main</em> thread itself)</li>
  </ol>
  
  <p>My observations is that <code>onLoadFinished</code> method always gets called before the first call to <code>onReceive</code>. That is, the <code>CursorLoader</code> takes precedence over the <code>BroadcastReciever</code>. Moreover, the <code>onReceive</code> method of the <code>BroadcastReceiver</code> does not get called until the <code>onLoadFinished</code> method completes.</p>
  
  <p>Assuming that  :</p>
  
  <ol>
  <li>There is a foreground service already running in the background that is publishing messages for my <code>BroadcastReciever</code> even before the app is launched for the first time <strong>AND</strong> </li>
  <li>Considering that the <code>BroadcastReciever</code> is registered before the <code>CursorLoader</code> is started, shouldn't the <code>onReceive</code> method get triggered immediately considering there are already messages available for the <code>BroadcastReceiver</code>.</li>
  </ol>
  
  <p>Since this is not the case, I am lead to believe that the <code>CursorLoader</code> takes precedence over a <code>BroadcastReceiver</code> when started on the main thread of an activity. However, I can't seem to find any documentaiton for this.</p>
  
  <p>How can I ensure that my <code>BroadcastReceiver</code> gets precedence over the <code>CursorLoader</code>? This behavior is important because I want my <code>Activity</code> to be initialized with some information that is being broadcasted by the foreground service even if the app is being launched newly (i.e onCreate being called on the <code>ACtivity</code>). The <code>CursorLoader</code> needs this information to create the <code>Uri</code> to be used for fetching the relevant data and showing it on the UI. Since the <code>CursorLoader</code> runs before the <code>BroadcastReciever</code>, it constructs a <code>Uri</code> without this information and subsequently fetches stale data from the database.</p>