Search in sources :

Example 1 with NetworkReceiver

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);
}
Also used : NetworkReceiver(com.eros.framework.receiver.NetworkReceiver) IntentFilter(android.content.IntentFilter) DispatchEventManager(com.eros.framework.manager.impl.dispatcher.DispatchEventManager)

Aggregations

IntentFilter (android.content.IntentFilter)1 DispatchEventManager (com.eros.framework.manager.impl.dispatcher.DispatchEventManager)1 NetworkReceiver (com.eros.framework.receiver.NetworkReceiver)1