title: How to get the activity which called the BroadcastReceiver?
body: <p>I have a <code>BroadcastReceiver</code> which checks for NetworkChange, whether connected to Internet or not.</p>
  
  <p>So in my application when the network is disconnected or connected, I want to know which activity has called the <code>BroadcastReceiver</code>, so that I can go back to previous activity after showing an alert informing about the network.</p>
  
  <p>My code,</p>
  
  <pre><code>public class NetworkChangeReceiver extends BroadcastReceiver {
  
  private android.widget.Toast Toast;
  
  @Override
  public void onReceive(final Context context, final Intent intent) {
      try {
          boolean isVisible = MyApplication.isActivityVisible();
          Context appContext = context.getApplicationContext();
          if (isVisible == true) {
              if (checkInternet(context)) {
                  /*Intent i = new Intent(context, MainActivity.class);
                  i.addFlags(Intent.FLAG_ACTIVITY_NEW_TASK);
                  context.startActivity(i);*/
  
  
                  Toast.makeText(context, "Network Available Do operations", Toast.LENGTH_LONG).show();
              } else {
                  Intent i = new Intent(context, NoNetworkAlert.class);
                  i.addFlags(Intent.FLAG_ACTIVITY_NEW_TASK);
                  context.startActivity(i);
                  Toast.makeText(context, "Network NOT Available Do operations", Toast.LENGTH_LONG).show();
              }
  
    .........
    ......
  </code></pre>
  
  <p>Here in the above code, when Internet is reconnected, 
   <code>if (checkInternet(context))</code>I just want to get to the activity which triggered this.</p>