From 2892c426289084a80aa3317c0746f5e57d9ba37b Mon Sep 17 00:00:00 2001 From: Hemanth S Date: Sat, 16 May 2020 22:39:51 +0530 Subject: [PATCH] Update PreferenceUtil.java --- .../code/name/monkey/retromusic/util/PreferenceUtil.java | 5 ++++- 1 file changed, 4 insertions(+), 1 deletion(-) diff --git a/app/src/main/java/code/name/monkey/retromusic/util/PreferenceUtil.java b/app/src/main/java/code/name/monkey/retromusic/util/PreferenceUtil.java index 73ecba36..358b38de 100644 --- a/app/src/main/java/code/name/monkey/retromusic/util/PreferenceUtil.java +++ b/app/src/main/java/code/name/monkey/retromusic/util/PreferenceUtil.java @@ -173,7 +173,10 @@ public final class PreferenceUtil { case "only_wifi": final ConnectivityManager connectivityManager = (ConnectivityManager) context .getSystemService(Context.CONNECTIVITY_SERVICE); - NetworkInfo netInfo = connectivityManager.getActiveNetworkInfo(); + NetworkInfo netInfo = null; + if (connectivityManager != null) { + netInfo = connectivityManager.getActiveNetworkInfo(); + } return netInfo != null && netInfo.getType() == ConnectivityManager.TYPE_WIFI && netInfo .isConnectedOrConnecting(); case "never":