Example usage for android.net ConnectivityManager TYPE_VPN

List of usage examples for android.net ConnectivityManager TYPE_VPN

Introduction

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

Prototype

int TYPE_VPN

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

Click Source Link

Document

A virtual network using one or more native bearers.

Usage

From source file:com.avalond.ad_blocak.vpn.AdVpnService.java

private void connectivityChanged(Intent intent) {
    if (intent.getIntExtra(ConnectivityManager.EXTRA_NETWORK_TYPE, 0) == ConnectivityManager.TYPE_VPN) {
        Log.i(TAG, "Ignoring connectivity changed for our own network");
        return;//from www .j a  va2 s .c o m
    }

    if (!ConnectivityManager.CONNECTIVITY_ACTION.equals(intent.getAction())) {
        Log.e(TAG, "Got bad intent on connectivity changed " + intent.getAction());
    }
    if (intent.getBooleanExtra(ConnectivityManager.EXTRA_NO_CONNECTIVITY, false)) {
        Log.i(TAG, "Connectivity changed to no connectivity, wait for a network");
        waitForNetVpn();
    } else {
        Log.i(TAG, "Network changed, try to reconnect");
        reconnect();
    }
}