1

I am developing an app where I have to connect to a remote server through VPN. Presently I am using Android's inbuilt tool for VPN configuration and connection (Settings>More>VPN>...), which I have to activate and deactivate several times during the use of the app (the server blocks other internet connection when connected though this VPN, so I only want to establish it once in a while).

Here is the configuration necessary for that VPN connection: Name: arbitrary Type: IPSec Xauth PSK Server Address: known IPSec Identifier: known IPSec Pre-shared key: known Username: known Password: known

If I understood right, I could either run a background service to establish the connection and then activate/deactivate from the foreground/UI activity, or maybe just have an inbuilt method if that activity/class to establish the VPN connection when necessary.

I also know there is VpnService class but I think it is much more complex than what I need. I have seen suggestions on using OpenVPN source code but I get lost on where to pick it up. This as an example: Android: Sample Code to connect to VPN in Android 4.0 using VPNService API

Is it possible to have this inbuilt VPN? Could someone give me a hint on how to code it? Thanks in advance

EDIT: I also have found here that it is not possible configure an L2TP/IPSec, would it also apply to IPSec Xauth PSK?? Create L2TP/IPSec VPN base on VpnService programmatically in Android

Frederik
  • 33
  • 9
  • I would only need to understand which is the way to go, any help given is appreciated! – Frederik Feb 10 '20 at 15:54
  • I am currently setting up the service (new to me, Java beginner) from which the VPN could be activated/deactivated. – Frederik Feb 10 '20 at 15:54
  • In the following post https://stackoverflow.com/questions/50021979/how-to-create-ipsec-l2tp-psk-vpn-for-android It is said IPSec and L2TP cannot be accessed (Android's inbuilt VPN tools) in latest versions of Android. Are they accessible in Android 7.0 for example? – Frederik Feb 10 '20 at 16:26
  • I keep finding people asking the same (or very similar) questions, still not fully answered, in this case also with L2TP/IPSec: https://stackoverflow.com/questions/56966665/how-to-extend-vpnservice-to-open-an-l2tp-ipsec-connection-in-android-programmati – Frederik Feb 10 '20 at 17:54

0 Answers0