1. How to get network status
1 2 3 4 5 6 7 8 9 10 11 12 | public static void showNetworkStatus(Context context) { final ConnectivityManager connMgr = (ConnectivityManager)context.getSystemService(Context.CONNECTIVITY_SERVICE); boolean wifi = connMgr.getNetworkInfo(ConnectivityManager.TYPE_WIFI).isAvailable(); boolean mobile = connMgr.getNetworkInfo(ConnectivityManager.TYPE_MOBILE).isAvailable(); boolean bluetooth = false; if( android.os.Build.VERSION.SDK_INT >= android.os.Build.VERSION_CODES.HONEYCOMB_MR2 ) { bluetooth = connMgr.getNetworkInfo(ConnectivityManager.TYPE_BLUETOOTH).isAvailable(); } Toast.makeText(context, "wifi: " + wifi + ", mobile: " + mobile + ", bluetooth: " + bluetooth , Toast.LENGTH_SHORT).show(); } |
댓글 없음:
댓글 쓰기