Created
October 7, 2013 14:38
-
-
Save sakurabird/6869087 to your computer and use it in GitHub Desktop.
Androidのネットワーク接続チェック
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
/** | |
* ネットワーク接続チェック | |
* | |
* @param context | |
* @return | |
*/ | |
public static boolean isConnected() { | |
ConnectivityManager cm = (ConnectivityManager) MyApplication.getContext() | |
.getSystemService(Context.CONNECTIVITY_SERVICE); | |
NetworkInfo ni = cm.getActiveNetworkInfo(); | |
if (ni != null) { | |
return cm.getActiveNetworkInfo().isConnected(); | |
} | |
return false; | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment