Update PreferenceUtil.java

main
Hemanth S 2020-05-16 22:39:51 +05:30
parent 06413312ea
commit 2892c42628
1 changed files with 4 additions and 1 deletions

View File

@ -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":