[Free] Vpn Checker extension (check vpn status if connected or not)

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…
equal :x:
equals :x:
Screenshot_2024-06-30-02-31-32-24_40deb401b9ffe8e1df2f1cc5ba480b12

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.

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

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

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…