title: Access to application class in Broadcast Receiver
body: <p>I want to check internet connection in Broadcast Receiver; And set result (A boolean flag) to a global variable, to use it on whole application, in if conditions; That if internet is disconnected, set a status imageview in main activity, to red image, and if connected, set it to green.</p>
  
  <p>I followed <a href="https://stackoverflow.com/questions/1944656/android-global-variable">this</a> topic. But there is no <code>getApplication()</code> in Broadcast Receiver; And iI should use <code>getApplicationContext()</code> instead.</p>
  
  <p>On another side, <a href="https://stackoverflow.com/questions/5018545/getapplication-vs-getapplicationcontext">this</a> topic:</p>
  
  <blockquote>
    <p>when writing code in a broadcast receiver, which is not a context but
    is given a context in its onReceive method, you can only call
    getApplicationContext(). Which also means that you are not guaranteed
    to have access to your application in a BroadcastReceiver.</p>
  </blockquote>
  
  <ol>
  <li><p>What are the concerns?</p></li>
  <li><p>How can I access to my application class in broadcast Receiver?</p></li>
  <li><p>Is there better solution to check internet connection, set global variable and change my status imageview?</p></li>
  </ol>