use of com.eros.framework.receiver.NetworkReceiver in project WeexErosFramework by bmfe.
the class ConnectivityManager method registerNetworkListener.
public void registerNetworkListener(Context context, JSCallback callback) {
if (mCallbacks == null) {
mCallbacks = new ArrayList<>();
}
mCallbacks.add(callback);
if (mNetworkReceiver == null) {
mNetworkReceiver = new NetworkReceiver();
IntentFilter intentFilter = new IntentFilter();
intentFilter.addAction(android.net.ConnectivityManager.CONNECTIVITY_ACTION);
intentFilter.addAction(WifiManager.WIFI_STATE_CHANGED_ACTION);
intentFilter.addAction(WifiManager.NETWORK_STATE_CHANGED_ACTION);
context.registerReceiver(mNetworkReceiver, intentFilter);
}
DispatchEventManager dispatchEventManager = ManagerFactory.getManagerService(DispatchEventManager.class);
dispatchEventManager.getBus().register(this);
}
Aggregations