May I jump in to this topic ?
Before upgrade of OpenVPN Connect to 3.0 I used the following code in my app to start and stop the VPN-Connection.
Documented
here: yes, it was my post 😉
startVPN brought OpenVPN Connect to the foreground startet VPN-connection and then put OpenVPN Connect to the background - almost perfect 😉
private void startVPN() {
Intent openVPN = new Intent();
openVPN.setPackage("net.openvpn.openvpn");
openVPN.setClassName("net.openvpn.openvpn", "net.openvpn.openvpn.OpenVPNClient");
openVPN.putExtra("net.openvpn.openvpn.AUTOSTART_PROFILE_NAME", "my.company.com [openvpn]");
startActivity(openVPN);
}
stopVPN stopped the connection entirely in background - perfect.
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);
Since version 3.0 this is no longer supported and I tried to adapt the information provided above in this topic.
Currently I use v3.0.2
After some tries my app is able to launch OpenVPN Connect but it does no autoconnect :cry:
Stopping the connection works too but OpenVPN Connect stays in foreground.
Here the code I tried with lots of variations:
private void startVPN() {
Intent openVPN = new Intent();
openVPN.setPackage("net.openvpn.openvpn");
openVPN.setClassName("net.openvpn.openvpn", "net.openvpn.unified.MainActivity");
openVPN.putExtra("net.openvpn.openvpn.AUTOSTART_PROFILE_NAME", "my.company.com [openvpn]");
openVPN.putExtra("net.openvpn.openvpn.AUTOCONNECT", "true");
startActivity(openVPN);
}
private void stopVPN() {
Intent openVPN = new Intent("net.openvpn.openvpn.DISCONNECT");
openVPN.setPackage("net.openvpn.openvpn");
openVPN.setClassName("net.openvpn.openvpn", "net.openvpn.unified.MainActivity");
openVPN.putExtra("net.openvpn.openvpn.STOP", "true");
startActivityForResult(openVPN, 0);
Does anybody know what's wrong or missing ?
Any help is very much appreciated.
Bye the way:
I wouldn't mind getting a hint how to start the VPN connection completly in background.
See
this post.