Skip to content
Open
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -2,14 +2,17 @@

import android.content.Context;
import android.net.ConnectivityManager;
import android.net.NetworkInfo;

public class NetworkUtils {

public static boolean isAvailable(Context context) {
ConnectivityManager manager = (ConnectivityManager) context.getSystemService(
Context.CONNECTIVITY_SERVICE);
if (manager != null) {
return manager.getActiveNetworkInfo() != null;
NetworkInfo activeNetworkInfo = manager.getActiveNetworkInfo();
NetworkInfo vpnInfo = manager.getNetworkInfo(ConnectivityManager.TYPE_VPN);
return activeNetworkInfo != null || (vpnInfo != null && vpnInfo.isConnected());
Comment thread
Linus789 marked this conversation as resolved.
}
return false;
}
Expand Down