Created
May 30, 2020 19:34
-
-
Save prolongservices/96fa2aaa27eca55a967ec6fda4e3cdec to your computer and use it in GitHub Desktop.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| public static boolean isConnectionAvailable(Context context) { | |
| ConnectivityManager connectivityManager = (ConnectivityManager) context | |
| .getSystemService(Context.CONNECTIVITY_SERVICE); | |
| if (connectivityManager != null) { | |
| NetworkInfo netInfo = connectivityManager.getActiveNetworkInfo(); | |
| if (netInfo != null && netInfo.isConnected() | |
| && netInfo.isConnectedOrConnecting() | |
| && netInfo.isAvailable()) { | |
| return true; | |
| } | |
| } | |
| return false; | |
| } | |
| public static void l(String TAG, String msg) { | |
| Log.d(TAG, msg); | |
| } | |
| public static void l(String TAG, Throwable e) { | |
| Log.e(TAG, "",e); | |
| } |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment