VPN condition?

Post your questions and help other users.

Moderator: Martin

Post Reply
Wibbly
Posts: 418
Joined: 17 Mar 2014 09:02

VPN condition?

Post by Wibbly » 13 Apr 2019 08:05

Does anyone know of a way to test if a VPN is running?

anuraag
Posts: 371
Joined: 24 Jan 2015 02:06

Re: VPN condition?

Post by anuraag » 13 Apr 2019 08:38

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()");

Wibbly
Posts: 418
Joined: 17 Mar 2014 09:02

Re: VPN condition?

Post by Wibbly » 13 Apr 2019 09:27

Thanks. Will give it a go.

Post Reply