Skip to content

NEW Methods: NetworkUtils: isBehindProxy(), isUsingVPN() (All APIs supported)#1492

Merged
Blankj merged 1 commit into
Blankj:masterfrom
XiXiongMaoXiong:patch-4
Dec 5, 2021
Merged

NEW Methods: NetworkUtils: isBehindProxy(), isUsingVPN() (All APIs supported)#1492
Blankj merged 1 commit into
Blankj:masterfrom
XiXiongMaoXiong:patch-4

Conversation

@XiXiongMaoXiong

Copy link
Copy Markdown
Contributor
  1. isBehindProxy():
    Returns true if device is connecting to the internet via a proxy, works for both Wi-Fi and Mobile Data.
    Code:
    public static boolean isBehindProxy(){ return !(System.getProperty("http.proxyHost") == null || System.getProperty("http.proxyPort") == null); }

  2. isUsingVPN():
    Returns true if device is connecting to the internet via a VPN.
    public static boolean isUsingVPN(){ ConnectivityManager cm = (ConnectivityManager) com.blankj.utilcode.util.Utils.getApp().getSystemService(Context.CONNECTIVITY_SERVICE); if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.P) { return cm.getNetworkInfo(ConnectivityManager.TYPE_VPN).isConnectedOrConnecting() } else { return cm.getNetworkInfo(NetworkCapabilities.TRANSPORT_VPN).isConnectedOrConnecting() } }

1. isBehindProxy():
Returns true if device is connecting to the internet via a proxy, works for both Wi-Fi and Mobile Data.
2. isUsingVPN():
Returns true if device is connecting to the internet via a VPN.
@XiXiongMaoXiong

Copy link
Copy Markdown
Contributor Author

@Blankj

@XiXiongMaoXiong XiXiongMaoXiong changed the title Added yet another 2 very useful methods NEW Methods: NetworkUtils: isBehindProxy(), isUsingVPN() (All APIs supported) May 9, 2021
@XiXiongMaoXiong

Copy link
Copy Markdown
Contributor Author

@Blankj 他妈的,兄弟!?

@XiXiongMaoXiong

Copy link
Copy Markdown
Contributor Author

@Blankj what the fuck are you doing mate!? Its almost a fucking year that you did not merge!

@Blankj Blankj merged commit 57fbefa into Blankj:master Dec 5, 2021
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants