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

3.23 getVPNStatus Android Example

I. Providing JSON as a parameter:

VPNSDK.CmdProc("{\"cmd\": 5}");

Result of this command will be returned using onNotify method provided on initialization

II. Convenient form:

VPNSDK.CommandNotifyCB callback = new VPNSDK.CommandNotifyCB() {
        @Override
        public void onNotify(int notification, int error, Object data) {
            if (error == VPNSDK.OVS_ERROR_CODES.OVS_ERR_OK) {
                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;
                    }
                }
            } else {
                // Process error
            }
        }
    };
VPNSDK.CmdProc(VPNSDK.OVS_CMD_CODES.OVS_CMD_GET_STATUS, callback);

This form of method accepts following parameters:

  1. Command code
  2. Callback to be invoked after command execution

data parameter of callback will contain Map of the following structure:

{
    VPN_Status": 1 
}