VPN condition?
Moderator: Martin
VPN condition?
Does anyone know of a way to test if a VPN is running?
Re: VPN condition?
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()");