Pick up the-android to get the current phone's memory card status and network connection status

Source: Internet
Author: User

Preface:

A person's life is a process of choice.

If the foot only a road, as long as indomitable can, do not worry about going wrong. Even if it is wrong, there is no other way. However, people are restless, and is comfortable with the walk of the Plank Road, its destination because there is no winding twists and turns to block the line of sight, Indomitable saw the head, is both the end. So often from the bottom of the heart of the change of mind, has made their way to the end of the road to enjoy different landscapes. The result of the selection is the same, and the difference is the difference of experience. It is unrealistic to be born equal, so use all to defend the right of choice.

There is no life without a choice.

The universe is the only or countless, sci-fi or fantasy, about their own may have an impact, perhaps only a miserable life will consider this annoying problem.

I only know that I am a programmer, or as a programmer, I like all people, but in the depths of the heart to hide such a space, mixed chaos chaos, the world is not divided.

I work here and pile up the fruits of the harvest every time. Pick up some of the sold here:

Determine if the current network is available:

1      Public Static BooleanChecknetworkstatus (Context context) {2         Booleanresult;3Connectivitymanager cm =(connectivitymanager) Context4 . Getsystemservice (context.connectivity_service);5Networkinfo NetInfo =cm.getactivenetworkinfo ();6         if(NetInfo! =NULL&&netinfo.isconnected ()) {7result =true;8LOG.I ("Netstatus", "The net was connected");9}Else {Tenresult =false; OneLOG.I ("Netstatus", "The net Wasa bad!"); A         } -         returnresult; -}

The type of connection can be judged by Networkinfo object Netinfo.gettype ().

It is relatively simple to determine whether an SD card is currently inserted:

    public static Boolean getexternalstoragestate () {        return Environment.MEDIA_MOUNTED.equals (Environment                . Getexternalstoragestate ());    }

To get the screen size:

1  Public Static displaymetrics getdisplaymetrics (activity activity) {2         New displaymetrics (); 3         Activity.getwindowmanager (). Getdefaultdisplay (). Getmetrics (DM); 4         return DM; 5     }

Pick up the-android to get the current phone's memory card status and network connection status

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.