Unified in-app VPN SDK's for Microsoft Windows Vista+, Android 4.4+ and Mac OS 10.7+. Earlier OS versions can be supported as well by request. Please contact [email protected] to receive your own API key.

Copyright © 2019 VPNWholesaler.com. All rights reserved.

Back

2.1 InitOVSCore Android Example

It is recommended to implement event listener in your Activity class in the following way:

public class MainActivity extends BaseActivity implements VPNSDK.CommandNotifyCB {
    @Override
    public void onNotify(int notification, int error, Object data) {
        switch (notification) {
            // Following is called when VPN status was changed 
            case VPNSDK.OVS_NOTIFY_CODES.OVS_NOTIFY_VPN_CONNECT_FAILED:
            case VPNSDK.OVS_NOTIFY_CODES.OVS_NOTIFY_VPN_ABNOMARLY_DISCONNECTED:
            case VPNSDK.OVS_NOTIFY_CODES.OVS_NOTIFY_VPN_DISCONNECTED: {
                // Do something when VPN was disconnected
                break;
            }
            case VPNSDK.OVS_NOTIFY_CODES.OVS_NOTIFY_VPN_CONNECTING: {
                // Do something when VPN was started to connect
                break;
            }
            case VPNSDK.OVS_NOTIFY_CODES.OVS_NOTIFY_VPN_CONNECTED: {
                // Do something when VPN was connected
                break;
            }
            // Following is called when we request VPN status explicitly

            case VPNSDK.OVS_NOTIFY_CODES.OVS_NOTIFY_GET_STATUS: {
                int state = (Integer)((Map)data).get("VPN_Status");
                switch (state) {
                    case VPNSDK.VPN_NOTIFY_STATUS.VPN_NOTIFY_DISCONNECTED:
                    case VPNSDK.VPN_NOTIFY_STATUS.VPN_NOTIFY_ABNORMALLY_DISCONNECTED:
                    case VPNSDK.VPN_NOTIFY_STATUS.VPN_NOTIFY_CONN_FAILED: {
                        // Do something when VPN was disconnected
                        break;
                    }
                    case VPNSDK.VPN_NOTIFY_STATUS.VPN_NOTIFY_ASSIGNIP:
                    case VPNSDK.VPN_NOTIFY_STATUS.VPN_NOTIFY_GETCONFIG:
                    case VPNSDK.VPN_NOTIFY_STATUS.VPN_NOTIFY_AUTH:
                    case VPNSDK.VPN_NOTIFY_STATUS.VPN_NOTIFY_CONNECTING: {
                        // Do something when VPN was started to connect
                        break;
                    }
                    case VPNSDK.VPN_NOTIFY_STATUS.VPN_NOTIFY_CONNECTED: {
                        // Do something when VPN was connected
                        break;
                    }
                }

            break;
        }
    }
    }
}

Then we can initialize SDK with the following code:

VPNSDK.InitOVSCore(this, this);