I have a broadcast set up as such in my manifest to monitor connection activity:
<application
...
<receiver
android:name="com.blah.appname.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>
...
</application>
Inside NetworkChangeReceiver is the onHandle() method. This is mainly just to show a Toast message, and do some logging, and works across the entire app.
public class NetworkChangeReceiver extends BroadcastReceiver {
@Override
public void onReceive(final Context context, final Intent intent) {
// do stuff
}
}
However, I also need to do special things in an individual activity based on the the loss of a connection.
How can I access the onReceive() method of the existing broadcast receiver from within an activity? I don't totally understand the internals of how the receiver is tied into the application from the manifest.