1 ./**
* Obtain the network connection method.
*
* @ Param context
* @ Return
*/
Public static NetworkInfo getActiveNetwork (Context context)
{
If (context = null)
Return null;
ConnectivityManager mConnMgr = (ConnectivityManager) context
. GetSystemService (Context. CONNECTIVITY_SERVICE );
If (mConnMgr = null)
Return null;
NetworkInfo aActiveInfo = mConnMgr. getActiveNetworkInfo ();
// Obtain the active network connection information
Return aActiveInfo;
}
PS: network if (null! = NetworkInfo getActiveNetwork (Context context ))
2 ./**
* Determine whether the SD card can be read and written
*
* @ Return
*/
Public static boolean isCanUseSdCard ()
{
Try
{
Return Environment. getExternalStorageState (). equals (
Environment. MEDIA_MOUNTED );
}
Catch (Exception e)
{
E. printStackTrace ();
}
Return false;
}
3 ./**
* Checks whether all strings are Chinese characters.
*
* @ Param name
* @ Return
*/
Public static boolean checkNameChese (String name)
{
Boolean res = true;
Char [] cTemp = name. toCharArray ();
For (int I = 0; I <name. length (); I ++)
{
If (! IsChinese (cTemp [I])
{
Res = false;
Break;
}
}
Return res;
}
4 ./**
* Read local or network images and convert them to Bitmap
*
* @ Param url
* @ Return
*/
Public static Bitmap returnBitmap (String url)
{
URL myFileUrl = null;
Bitmap bitmap = null;
Try
{
MyFileUrl = new URL (url );
}
Catch (MalformedURLException e)
{
E. printStackTrace ();
}
Try
{
HttpURLConnection conn = (HttpURLConnection) myFileUrl
. OpenConnection ();
Conn. setDoInput (true );
Conn. connect ();
InputStream is = conn. getInputStream ();
Bitmap = BitmapFactory. decodeStream (is );
Is. close ();
}
Catch (IOException e)
{
E. printStackTrace ();
}
Return bitmap;
}