I have configured a VPN connection in my Android phone. Now I would like to connect this VPN via a widget. How can I initiate a connection programmatically? Most code assumes there is no VPN setup yet, but this is not where I am looking for. I look especially for code which connects to an already configured VPN.
On http://code.google.com/p/android/issues/detail?id=8915 I have found this code:
VpnService service = context.getSystemService(VPN_SERVICE);
VpnProfile profile = VpnProfile.create(L2TP_PROFILE);
profile.setName(myServerName);
profile.setServerName(myServerAddress);
profile.setRouteList(“192.168.1.0/255.255.255.0,192.168.10.0/255.255.255.0”);
service.connect(profile, myUserName, myPassword);
service.setNotificationIntent(myIntent);
Which configures a new VPN. I want just to connect an existing VPN.
This page http://developer.android.com/reference/android/net/VpnService.html describes how to implement your own VPN service, which is also not what I am looking for.
Here the example of using VpnService https://android.googlesource.com/platform/development/+/master/samples/ToyVpn/src/com/example/android/toyvpn
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With