Page 1 of 1

VPN condition?

Posted: 13 Apr 2019 08:05
by Wibbly
Does anyone know of a way to test if a VPN is running?

Re: VPN condition?

Posted: 13 Apr 2019 08:38
by anuraag
Below code works on my oreo. vpnconnected will return true or false

Code: Select all

ctx=getContext();
cm=callJavaMethod(ctx, "android.content.Context", "getSystemService(java.lang.String)", "connectivity");

vpnconnected=callJavaMethod(callJavaMethod(cm, "android.net.ConnectivityManager", "getNetworkInfo(int)", getJavaStaticField("android.net.ConnectivityManager", "TYPE_VPN")), "android.net.NetworkInfo", "isConnectedOrConnecting()");

Re: VPN condition?

Posted: 13 Apr 2019 09:27
by Wibbly
Thanks. Will give it a go.