Chao Hua Xi-android gets the memory card status and network connection status of the current mobile phone, Chao Hua Xi-android

Source: Internet
Author: User

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     }

 

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.