Example usage for android.net ConnectivityManager CONNECTIVITY_ACTION

List of usage examples for android.net ConnectivityManager CONNECTIVITY_ACTION

Introduction

In this page you can find the example usage for android.net ConnectivityManager CONNECTIVITY_ACTION.

Prototype

String CONNECTIVITY_ACTION

To view the source code for android.net ConnectivityManager CONNECTIVITY_ACTION.

Click Source Link

Document

A change in network connectivity has occurred.

Usage

From source file:com.inaetics.demonstrator.MainActivity.java

@Override
protected void onStart() {
    super.onStart();
    registerReceiver(mConnReceiver, new IntentFilter(ConnectivityManager.CONNECTIVITY_ACTION));
}

From source file:com.ideateam.plugin.IsOnline.java

@Override
public void onResume(boolean multitasking) {
    // TODO Auto-generated method stub

    this.cordova.getActivity().registerReceiver(mConnReceiver,
            new IntentFilter(ConnectivityManager.CONNECTIVITY_ACTION));
    super.onResume(multitasking);

}

From source file:ar.com.iron.android.extensions.connections.InetDataClient.java

/**
 * Inicializa los listeners para conocer el estado actual de la red
 *///  w  ww .  j a va 2  s .  c  o  m
private void initListeners() {
    getIntentReceptor().registerMessageReceiver(ConnectivityManager.CONNECTIVITY_ACTION,
            new BroadcastReceiver() {
                @Override
                public void onReceive(Context context, Intent intent) {
                    onConnectivityChanged(intent);
                }
            });
}

From source file:com.seamusdawkins.rest.MainActivity.java

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

    setToolbar();//  w w  w . j a  v a 2 s . c om
    initUI(); //maps xml interface with java

    recyclerViewDevelop(); //setting recycleview
    swipeToRefresh(); // setup swipe to refresh
    checkConnection(); //check connection with internet

    filters = new IntentFilter(ConnectivityManager.CONNECTIVITY_ACTION);

}

From source file:com.tonyodev.fetch.Fetch.java

private Fetch(Context context) {

    this.context = context.getApplicationContext();

    this.broadcastManager = LocalBroadcastManager.getInstance(this.context);
    this.dbHelper = DatabaseHelper.getInstance(this.context);
    this.dbHelper.setLoggingEnabled(isLoggingEnabled());

    broadcastManager.registerReceiver(updateReceiver, FetchService.getEventUpdateFilter());

    this.context.registerReceiver(networkReceiver, new IntentFilter(ConnectivityManager.CONNECTIVITY_ACTION));

    startService(this.context);
}

From source file:org.apache.cordova.core.NetworkManager.java

/**
 * Sets the context of the Command. This can then be used to do things like
 * get file paths associated with the Activity.
 *
 * @param cordova The context of the main Activity.
 * @param webView The CordovaWebView Cordova is running in.
 *//*  w ww. j  a va2s. c o m*/
public void initialize(CordovaInterface cordova, CordovaWebView webView) {
    super.initialize(cordova, webView);
    this.sockMan = (ConnectivityManager) cordova.getActivity().getSystemService(Context.CONNECTIVITY_SERVICE);
    this.connectionCallbackContext = null;

    // We need to listen to connectivity events to update navigator.connection
    IntentFilter intentFilter = new IntentFilter();
    intentFilter.addAction(ConnectivityManager.CONNECTIVITY_ACTION);
    if (this.receiver == null) {
        this.receiver = new BroadcastReceiver() {
            @Override
            public void onReceive(Context context, Intent intent) {
                // (The null check is for the ARM Emulator, please use Intel Emulator for better results)
                if (NetworkManager.this.webView != null)
                    updateConnectionInfo(sockMan.getActiveNetworkInfo());
            }
        };
        cordova.getActivity().registerReceiver(this.receiver, intentFilter);
        this.registered = true;
    }

}

From source file:com.polyvi.xface.extension.bluetooth.XBluetoothExt.java

@Override
public void initialize(CordovaInterface cordova, CordovaWebView webView) {
    mCordova = cordova;//w w w.  jav a  2  s. c  o m
    try {
        mBtadapter = BluetoothAdapter.getDefaultAdapter();
    } catch (RuntimeException e) {
        XLog.e(CLASS_NAME, "init: RuntimeException");
        return;
    }
    mFoundDevices = new ArrayList<BluetoothDevice>();
    Context context = cordova.getActivity();

    IntentFilter filter = new IntentFilter(BluetoothDevice.ACTION_FOUND);
    context.registerReceiver(mReceiver, filter);

    filter = new IntentFilter(BluetoothAdapter.ACTION_DISCOVERY_STARTED);
    context.registerReceiver(mReceiver, filter);

    filter = new IntentFilter(BluetoothAdapter.ACTION_DISCOVERY_FINISHED);
    context.registerReceiver(mReceiver, filter);

    filter = new IntentFilter(ConnectivityManager.CONNECTIVITY_ACTION);
    context.registerReceiver(mReceiver, filter);
}

From source file:cn.bingoogolapple.scaffolding.util.AppManager.java

private AppManager() {
    // ?//  w ww  .  ja  va 2s  .  co  m
    CrashHandler.getInstance().init();

    sApp.registerReceiver(new BroadcastReceiver() {
        private boolean mIsFirstReceiveBroadcast = true;

        @Override
        public void onReceive(Context context, Intent intent) {
            if (intent.getAction().equals(ConnectivityManager.CONNECTIVITY_ACTION)) {
                if (!mIsFirstReceiveBroadcast) {
                    try {
                        if (NetUtil.isNetworkAvailable()) {
                            RxBus.send(new RxEvent.NetworkConnectedEvent());
                        } else {
                            RxBus.send(new RxEvent.NetworkDisconnectedEvent());
                        }
                    } catch (Exception e) {
                    }
                } else {
                    mIsFirstReceiveBroadcast = false;
                }
            }
        }
    }, new IntentFilter(ConnectivityManager.CONNECTIVITY_ACTION));
}

From source file:de.flyingsnail.ipv6droid.android.AyiyaVpnService.java

/**
 * Register the instance of connectivityReceiver for global CONNECTIVITY_ACTIONs.
 */// w ww  . jav a  2 s . c o m
private void registerGlobalConnectivityReceiver() {
    final IntentFilter intentFilter = new IntentFilter(ConnectivityManager.CONNECTIVITY_ACTION);
    getApplicationContext().registerReceiver(connectivityReceiver, intentFilter);
    Log.d(TAG, "registered CommandReceiver for global broadcasts");
}

From source file:com.example.testplayer.NetworkManager.java

/**
 * Sets the context of the Command. This can then be used to do things like
 * get file paths associated with the Activity.
 *
 * @param cordova The context of the main Activity.
 * @param webView The CordovaWebView Cordova is running in.
 *///www . j av a  2s . co  m
public void initialize(CordovaInterface cordova, CordovaWebView webView) {
    super.initialize(cordova, webView);
    this.sockMan = (ConnectivityManager) cordova.getActivity().getSystemService(Context.CONNECTIVITY_SERVICE);
    this.connectionCallbackContext = null;

    // We need to listen to connectivity events to update navigator.connection
    IntentFilter intentFilter = new IntentFilter();
    intentFilter.addAction(ConnectivityManager.CONNECTIVITY_ACTION);
    if (this.receiver == null) {
        this.receiver = new BroadcastReceiver() {
            @Override
            public void onReceive(Context context, Intent intent) {
                // (The null check is for the ARM Emulator, please use Intel Emulator for better results)
                if (NetworkManager.this.webView != null)
                    updateConnectionInfo(sockMan.getActiveNetworkInfo());
            }
        };
        webView.getContext().registerReceiver(this.receiver, intentFilter);
    }

}