How can I programmatically connect and disconnect vpn connections using the openvpn connect android application in conjunction with intentions?

I am working on an Android application that should start an OpenVPN Connect session automatically when necessary.

How can I programmatically connect and disconnect vpn connections using the openvpn connect android application in conjunction with intentions?

Edit: In the meantime, I found this approach - it works for me:

private void startVPN() { Intent openVPN = new Intent("android.intent.action.VIEW"); openVPN.setPackage("net.openvpn.openvpn"); openVPN.setClassName("net.openvpn.openvpn", net.openvpn.openvpn.OpenVPNClient"); openVPN.putExtra("net.openvpn.openvpn.AUTOSTART_PROFILE_NAME", "10.10.10.10 [profilename]"); startActivityForResult(openVPN, 0); } 

This launches the OpenVPN Connect application and uses the profile name for automatic connection.

If the application successfully goes into the background,

Is there a way to do this completely in the background?
Stopping a VPN connection does everything in the background.

 private void stopVPN() { Intent openVPN = new Intent("android.intent.action.VIEW"); openVPN.setPackage("net.openvpn.openvpn"); openVPN.setClassName("net.openvpn.openvpn", "net.openvpn.openvpn.OpenVPNDisconnect"); startActivityForResult(openVPN, 0); } 
+7
android android-intent openvpn
source share
1 answer

The official Android OpenVPN client can be called through AIDL. There is available only a sample application, with source code . It even has a relatively friendly license.

+2
source share

All Articles