Chao Hua Xi-android gets the memory card status and network connection status of the current mobile phone, Chao Hua Xi-android
Preface:
A person's life is a process of choice.
If there is only one path under your feet, you just need to move forward without worrying about going wrong. Even if it is wrong, there is no other way. However, people are restless. Moreover, as they walk on zhuanqiao, their destination is not winding and twists and turns to block the line of sight of passers-. As a result, a changing heart is often triggered from the bottom of my heart, so that you can see different scenery on the way to the end. The results of the selection are the same. The difference is that the experience is different. Being born and equal is impractical, so we should use all rights to defend the choice.
No choice means no life.
The universe is the only one, countless, sci-fi or mysterious, and may have an impact on yourself. Maybe only a miserable life will consider this annoying question.
I only know that I am a programmer, or I am a programmer. I am the same as everyone else, but in the depth of my heart, there is no point in this space.
I am working here, and every time I build up a pile of fruits. Pick up some items to sell here:
Determine whether the current network is available:
1 public static boolean checkNetWorkStatus(Context context) { 2 boolean result; 3 ConnectivityManager cm = (ConnectivityManager) context 4 .getSystemService(Context.CONNECTIVITY_SERVICE); 5 NetworkInfo netinfo = cm.getActiveNetworkInfo(); 6 if (netinfo != null && netinfo.isConnected()) { 7 result = true; 8 Log.i("NetStatus", "The net was connected"); 9 } else {10 result = false;11 Log.i("NetStatus", "The net wasa bad!");12 }13 return result;14 }
The NetworkInfo object netinfo. getType () can be used to determine the connection type.
It is relatively simple to determine whether an SD card is inserted:
public static boolean getExternalStorageState() { return Environment.MEDIA_MOUNTED.equals(Environment .getExternalStorageState()); }
Get screen size:
1 public static DisplayMetrics getDisplayMetrics(Activity activity) {2 DisplayMetrics dm = new DisplayMetrics();3 activity.getWindowManager().getDefaultDisplay().getMetrics(dm);4 return dm;5 }