得到电话状态(WIFI状态,厂商,运营商等)的工具类
得到电话的状态,包括手机版本,厂商,运营商,型号,WIFI状态等等;无需多言,一看就懂的傻瓜贴。
需要在AndroidManifest.xml中注册如下权限
[html]
<uses-permission android:name="android.permission.READ_PHONE_STATE"/>
<uses-permission android:name="android.permission.ACCESS_NETWORK_STATE"/>
[java]
package com.jamin.phone_info;
import java.io.BufferedReader;
import java.io.FileNotFoundException;
import java.io.FileReader;
import java.io.IOException;
import android.Manifest;
import android.app.Activity;
import android.app.ActivityManager;
import android.app.ActivityManager.MemoryInfo;
import android.content.Context;
import android.content.pm.PackageManager;
import android.net.ConnectivityManager;
import android.net.NetworkInfo;
import android.os.Build;
import android.telephony.TelephonyManager;
import android.util.Log;
public class PhoneInfo {
private static final String TAG = PhoneInfo.class.getSimpleName();
private static final String FILE_MEMORY = "/proc/meminfo";
private static final String FILE_CPU = "/proc/cpuinfo";
public String mIMEI;
public int mPhoneType;
public int mSysVersion;
public String mNetWorkCountryIso;
public String mNetWorkOperator;
public String mNetWorkOperatorName;
public int mNetWorkType;
public boolean mIsOnLine;
public String mConnectTypeName;
public long mFreeMem;
public long mTotalMem;
public String mCupInfo;
public String mProductName;
public String mModelName;
public String mManufacturerName;
/**
* private constructor
*/
private PhoneInfo() {
}
/**
* get imei
* @return
*/
public static String getIMEI(Context context) {
TelephonyManager manager = (TelephonyManager) context
.getSystemService(Activity.TELEPHONY_SERVICE);
// check if has the permission
if (PackageManager.PERMISSION_GRANTED == context.getPackageManager()
.checkPermission(Manifest.permission.READ_PHONE_STATE,
context.getPackageName())) {
return manager.getDeviceId();
} else {
return null;
}
}
/**
* get phone type,like :GSM��CDMA��SIP��NONE
*
* @param context
* @return
*/
public static int getPhoneType(Context context) {
TelephonyManager manager = (TelephonyManager) context
.getSystemService(Activity.TELEPHONY_SERVICE);
return manager.getPhoneType();
}
/**
* get phone sys version
*
* @return
*/
public static int getSysVersion() {
return Build.VERSION.SDK_INT;
}
/**
* Returns the ISO country code equivalent of the current registered
* operator's MCC (Mobile Country Code).
*
* @param context
* @return
*/
&nbs
补充:移动开发 , Android ,