aboutsummaryrefslogtreecommitdiffstats
path: root/src/main/java/de/pixart
diff options
context:
space:
mode:
authorChristian Schneppe <christian@pix-art.de>2018-05-17 20:41:26 +0200
committerChristian Schneppe <christian@pix-art.de>2018-05-17 20:41:26 +0200
commitebf64ec78df62195b8e8c5e64b9b7c55037c5cdc (patch)
tree684e05518aa9885e47758ec237da27257bd97acc /src/main/java/de/pixart
parentd5b8ca261357c6b51182d4661d48112e47795b53 (diff)
add null check
Diffstat (limited to 'src/main/java/de/pixart')
-rw-r--r--src/main/java/de/pixart/messenger/services/XmppConnectionService.java8
1 files changed, 4 insertions, 4 deletions
diff --git a/src/main/java/de/pixart/messenger/services/XmppConnectionService.java b/src/main/java/de/pixart/messenger/services/XmppConnectionService.java
index c4a40c1a3..cae50e6e5 100644
--- a/src/main/java/de/pixart/messenger/services/XmppConnectionService.java
+++ b/src/main/java/de/pixart/messenger/services/XmppConnectionService.java
@@ -1002,7 +1002,7 @@ public class XmppConnectionService extends Service {
public boolean hasInternetConnection() {
final ConnectivityManager cm = (ConnectivityManager) getSystemService(Context.CONNECTIVITY_SERVICE);
try {
- final NetworkInfo activeNetwork = cm.getActiveNetworkInfo();
+ final NetworkInfo activeNetwork = cm == null ? null : cm.getActiveNetworkInfo();
return activeNetwork != null && activeNetwork.isConnected();
} catch (RuntimeException e) {
Log.d(Config.LOGTAG, "unable to check for internet connection", e);
@@ -1013,7 +1013,7 @@ public class XmppConnectionService extends Service {
public boolean isWIFI() {
final ConnectivityManager cm = (ConnectivityManager) getSystemService(Context.CONNECTIVITY_SERVICE);
try {
- final NetworkInfo activeNetwork = cm.getActiveNetworkInfo();
+ final NetworkInfo activeNetwork = cm == null ? null : cm.getActiveNetworkInfo();
if (activeNetwork != null) { // connected to the internet
if (activeNetwork.getType() == ConnectivityManager.TYPE_WIFI) {
return true;
@@ -1029,7 +1029,7 @@ public class XmppConnectionService extends Service {
public boolean isMobile() {
final ConnectivityManager cm = (ConnectivityManager) getSystemService(Context.CONNECTIVITY_SERVICE);
try {
- final NetworkInfo activeNetwork = cm.getActiveNetworkInfo();
+ final NetworkInfo activeNetwork = cm == null ? null : cm.getActiveNetworkInfo();
if (activeNetwork != null) { // connected to the internet
if (activeNetwork.getType() == ConnectivityManager.TYPE_MOBILE) {
if (!activeNetwork.isRoaming()) {
@@ -1047,7 +1047,7 @@ public class XmppConnectionService extends Service {
public boolean isMobileRoaming() {
final ConnectivityManager cm = (ConnectivityManager) getSystemService(Context.CONNECTIVITY_SERVICE);
try {
- final NetworkInfo activeNetwork = cm.getActiveNetworkInfo();
+ final NetworkInfo activeNetwork = cm == null ? null : cm.getActiveNetworkInfo();
if (activeNetwork != null) { // connected to the internet
if (activeNetwork.getType() == ConnectivityManager.TYPE_MOBILE) {
if (activeNetwork.isRoaming()) {