reza aprian
Apr 15, 2019
9:32 am

Can I Connect to VPN without third party apps?

I want to use VPN in all connection through my app.

Currently I follow the tutorial and some discussion on the forum to initiate VPN. I am using Cisco Anyconnect and
I successfully do the following code,

EnterpriseKnoxManager ekm = EnterpriseKnoxManager.getInstance(getApplicationContext());
String[] packageList = {""};
try {
    GenericVpnPolicy gm = ekm.getGenericVpnPolicy("",0);
    int successCreate = gm.createVpnProfile(ProfileJsonVpn); //return 0
    int successAdding = gm.addPackagesToVpn(packageList, "genericvpn"); //return 0
    int getState = gm.getState("genericvpn"); //return 0
    int successActivate = gm.activateVpnProfile ("genericvpn", true); //return 304, what is it? can't find on vpn error list
} catch (SecurityException e) {

I have two questions

1. the return code for profile creation show success and I can find the profile created on Anyconnectt apps,
but when I check my IP using the code below, it still shows the same value before and after the code.
Shouln't the ip changed if I successfully connect via vpn?

String ip = Formatter.formatIpAddress(wm.getConnectionInfo().getIpAddress());

2. Can I connect to vpn without any third party apps like Cisco Anyconnect?

Thanks in advance!

Best Regards