Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

How to Create VPN Profile and Connect to it in android Programmatically?

Tags:

android

vpn

We are developing an Android app that needs to connect to a VPN. The problem that we have is that the users that are going to use this app, do not have any knowledge about Creating VPN profiles, to connect then to it, and then to connect to the app etc.

So, we are obligated to find a way when our Application starts, to connect to the VPN (we will hard code all the requirements needed). But the problem is that we searched on the internet and we couldn't find anything :(.

I wanted to ask you, is there anyway to Create a VPN Profile programmatically, and then Connect to it after the creation?

The VPN Profile that we need (VPN profile data that wee need to fill):

Name: ________

Type: IPSec Xauth PSK

Servber address: __________

IPSec identifier: __________

IPSec pre-shared key: ___________

Username: ______________

Password: ______________

Thank you in advance :D

like image 963
Taulant Ymeri Avatar asked Nov 07 '14 14:11

Taulant Ymeri


People also ask

Can I create my own VPN on Android?

VPN support is baked into Android, so you can easily set it up via the phone's Settings menu without downloading an app. Open the Settings menu of the phone. Keep in mind that the instructions below may vary depending on what device you have. Tap on Wi-Fi & Internet or Wireless & networks.

What is VPN connection profile?

VPN Connection Profiles are used to assign tunneling IP's to client machines using DHCP servers or Global Address Pools during VPN tunnel establishment.

What is VPN profile in Android?

Android VPN options VPNs allow devices that aren't physically on a network to securely access the network. Android includes a built-in (PPTP, L2TP/IPSec, and IPSec) VPN client. Devices running Android 4.0 and later also support VPN apps.


1 Answers

To programmatically add VPN profiles, there doesn't seem to be any Android API to do this. There is a VPNService and VPNService.Builder classes that will allow you to create and connect a VPN within your application.

I believe what you're looking to do though is add a new entry in the Android settings VPN list. This can be done via Samsung KNOX for devices that support KNOX via this KNOX API: https://seap.samsung.com/api-references/android-premium/reference/com/sec/enterprise/knox/GenericVpnPolicy.html

like image 56
Wesley Bunton Avatar answered Sep 19 '22 15:09

Wesley Bunton