Intent Script to Connect and Disconnect OpenVPN

Solved
DM
Daniel Maniera
OPAL Associates GmbH (Germany)

Dear Support Community,

i'm not fimilar with Android Intents. I tried to figure it out how they work to get out a script but i'm out of ideas.

I tried to build my script by using different informations.

These might be the best:

CONNECT WITH PROFLE

Intent openVPN = new Intent("net.openvpn.openvpn.CONNECT"); openVPN.setPackage("net.openvpn.openvpn"); openVPN.setClassName("net.openvpn.openvpn", "net.openvpn.unified.MainActivity"); openVPN.putExtra("net.openvpn.openvpn.AUTOSTART_PROFILE_NAME", "PC MYPROFILENAME "); openVPN.putExtra("net.openvpn.openvpn.AUTOCONNECT", true); openVPN.putExtra("net.openvpn.openvpn.APP_SECTION", "PC"); if (openVPN.resolveActivity(getActivity().getPackageManager()) != null) { startActivity(openVPN); }

DISCONNECT

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); if (openVPN.resolveActivity(getActivity().getPackageManager()) != null) { startActivityForResult(openVPN, 0); }

I tried the disconnect first because it seamed to be the easier part and came up with different scripts but none of them worked:

sendintent -a "intent:#Intent;action=net.openvpn.openvpn.DISCONNECT;component=net.openvpn.openvpn;B.STOP=true;end;"

or

sendintent -a "intent:#Intent;action=net.openvpn.openvpn.DISCONNECT;B.STOP=true;end;"

or

sendintent -a "intent:#Intent;action=net.openvpn.openvpn.DISCONNECT;B.net.openvpn.openvpn.extra.STOP=true;end;"

I guess i've tried them all but unforunately none of them worked.

Hope you can help!

2 years ago
Android Scripting
ANSWERS