I have implemented a `NetworkChangeReceiver` which looks like this:

```
public class NetworkChangeReceiver extends BroadcastReceiver {

    @Override
    public void onReceive(Context context, Intent intent) {
        final ConnectivityManager connectionManager = (ConnectivityManager) context.getSystemService(Context.CONNECTIVITY_SERVICE);
        final NetworkInfo wifi = connectionManager.getNetworkInfo(ConnectivityManager.TYPE_WIFI);

        logMessage(context, "Network State has changed.");
        if (!wifi.isAvailable()) {
            logMessage(context, "Golly gosh. WiFi has gone away.");
        }
    }

    private void logMessage(Context context, String message) {
        Intent intent = new Intent("logging-event");
        intent.putExtra("message", message);
        LocalBroadcastManager.getInstance(context).sendBroadcast(intent);
    }
}

```

In my activity I have added a broadcast receiver as well:

```
private BroadcastReceiver mMessageReceiver = new BroadcastReceiver() {
      @Override
      public void onReceive(Context context, Intent intent) {
          String message = intent.getStringExtra("message");
          logMessages.add(message);
      }
};

@Override
protected void onCreate(Bundle savedInstanceState) {
    super.onCreate(savedInstanceState);
    setContentView(R.layout.activity_player);

    LocalBroadcastManager
            .getInstance(this)
            .registerReceiver(mMessageReceiver, new IntentFilter(("logging-event")));
}

```

`AndroidManifest.xml`

```
   <receiver android:name=".NetworkChangeReceiver"
        android:label="NetworkChangeReceiver">
        <intent-filter>
            <action android:name="android.net.conn.CONNECTIVITY_CHANGE" />
            <action android:name="android.net.wifi.WIFI_STATE_CHANGED" />
        </intent-filter>
    </receiver>

```

For reasons unknown, the onReceive method on the activity is not invoked though. Any idea why this could be? Maybe because of a different context used in the logging method? If I use a simple toast it comes through and also if I use the same logging method in a service where I can use the service itself as the context.