From b2e429b7a32242437c7f72ea26b8335278f02e14 Mon Sep 17 00:00:00 2001 From: Arseniy Borisov Date: Tue, 10 Jan 2017 15:34:37 +0300 Subject: [PATCH] add isNetworkConnected() method --- src/main/java/ru/touchin/templates/DeviceUtils.java | 10 ++++++++++ 1 file changed, 10 insertions(+) diff --git a/src/main/java/ru/touchin/templates/DeviceUtils.java b/src/main/java/ru/touchin/templates/DeviceUtils.java index 33d228b..bb77c52 100644 --- a/src/main/java/ru/touchin/templates/DeviceUtils.java +++ b/src/main/java/ru/touchin/templates/DeviceUtils.java @@ -180,6 +180,16 @@ public final class DeviceUtils { } + /** + * Detects if some network connected. + * + * @param context Application context + * @return true if network connected, false otherwise. + */ + public static boolean isNetworkConnected(@NonNull final Context context) { + return getNetworkType(context) != NetworkType.NONE; + } + private DeviceUtils() { }