mirror of
https://github.com/KDE/kdeconnect-android
synced 2025-08-31 22:25:08 +00:00
Never crash if there is a problem in isOnMobileNetwork
This commit is contained in:
@@ -18,6 +18,7 @@ public class NetworkHelper {
|
||||
if (android.os.Build.VERSION.SDK_INT < android.os.Build.VERSION_CODES.LOLLIPOP) {
|
||||
return false; //No good way to know it
|
||||
}
|
||||
try {
|
||||
boolean mobile = false;
|
||||
final ConnectivityManager connMgr = (ConnectivityManager) context.getSystemService(Context.CONNECTIVITY_SERVICE);
|
||||
Network[] networks = connMgr.getAllNetworks();
|
||||
@@ -47,6 +48,10 @@ public class NetworkHelper {
|
||||
e.printStackTrace();
|
||||
}
|
||||
}
|
||||
} catch(Exception e) {
|
||||
e.printStackTrace();
|
||||
Log.d("isOnMobileNetwork", "Something went wrong, but this is non-critical.");
|
||||
}
|
||||
return false;
|
||||
}
|
||||
|
||||
|
Reference in New Issue
Block a user