Write a short description
You can check Vpn is connected or not by this extension…
Add a picture of all the blocks
Here is the simple blocks of exntesion…
Event raised and return “true” if vpn connected else “false”
IMPORTANT NOTE:
you can’t use Logic and Math compare blocks just compare text block is working…
Download links here;
Extension:
Vpnchecker.aix (6.4 KB)
aia Project:
Vpnchecker.aia (10.2 KB)
Apk:
VPNChecker.apk (4.3 MB)
2 Likes
No need to use compare block, if your status parameter only return either true or false then you can directly set it in if then condition.
Boban
(Boban Stojmenovic)
#3
It returns string instead of boolean.
@Professional make Status return boolean instead
2 Likes
yes its Return true or false but in string form instead of boolean…soo we need to use comapre text block…
You can do like this:
@SimpleFunction(description = "Returns true if the device is connected to a VPN")
public boolean IsConnectedToVPN() {
ConnectivityManager connectivityManager =
(ConnectivityManager) this.context.getSystemService(Context.CONNECTIVITY_SERVICE);
Network activeNetwork = connectivityManager.getActiveNetwork();
if (activeNetwork != null) {
NetworkCapabilities capabilities = connectivityManager.getNetworkCapabilities(activeNetwork);
return capabilities != null && capabilities.hasTransport(NetworkCapabilities.TRANSPORT_VPN);
}
return false;
}
3 Likes
Taifun
#6
As already mentioned earlier, follow the naming conventions
Status → status
Taifun
1 Like
It is returning a string value, instead of Boolean value, which can helps alot.
yes, you can use compare block as i mentioned in post
rapida959595
(Хозяин Гоши Гительман)
#9
why is this extension needed? we can already see the VPN connection status
you can check vpn is connected or not in your kodular app… you can restrict user to use vpn when your app is active…