2
0
mirror of https://github.com/KDE/kdeconnect-android synced 2025-09-02 15:15:09 +00:00

Never crash if there is a problem in isOnMobileNetwork

This commit is contained in:
Albert Vaca
2017-05-24 00:29:33 +02:00
parent 82b42fda67
commit 124a971a1f

View File

@@ -18,6 +18,7 @@ public class NetworkHelper {
if (android.os.Build.VERSION.SDK_INT < android.os.Build.VERSION_CODES.LOLLIPOP) { if (android.os.Build.VERSION.SDK_INT < android.os.Build.VERSION_CODES.LOLLIPOP) {
return false; //No good way to know it return false; //No good way to know it
} }
try {
boolean mobile = false; boolean mobile = false;
final ConnectivityManager connMgr = (ConnectivityManager) context.getSystemService(Context.CONNECTIVITY_SERVICE); final ConnectivityManager connMgr = (ConnectivityManager) context.getSystemService(Context.CONNECTIVITY_SERVICE);
Network[] networks = connMgr.getAllNetworks(); Network[] networks = connMgr.getAllNetworks();
@@ -47,6 +48,10 @@ public class NetworkHelper {
e.printStackTrace(); e.printStackTrace();
} }
} }
} catch(Exception e) {
e.printStackTrace();
Log.d("isOnMobileNetwork", "Something went wrong, but this is non-critical.");
}
return false; return false;
} }