IMEI号,IESI号,手机型号:
[java]?
view plain
copy
print
?
- private?void?getInfo()?{????
- ?????????????TelephonyManager?mTm?=?(TelephonyManager)?getSystemService(TELEPHONY_SERVICE);????
- ?????????????String?imei?=?mTm.getDeviceId();????
- ?????????????String?imsi?=?mTm.getSubscriberId();????
- ?????????????String?mtype?=?android.os.Build.MODEL;?//?手机型号????
- ?????????????String?numer?=?mTm.getLine1Number();?//?手机号码,有的可得,有的不可得????
- ?????????}??
public void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
setContentView(R.layout.main);
TextView textView = (TextView) findViewById(R.id.text);
textView.setText("Product Model: " + android.os.Build.MODEL + ","
+ android.os.Build.VERSION.SDK + ","
+ android.os.Build.VERSION.RELEASE);
}
String |
MODEL |
The end-user-visible name for the end product. |
String |
SDK |
This constant is deprecated. Use?SDK_INT ?to easily get this as an integer. |
String |
RELEASE |
The user-visible version string. |
String |
BOARD |
The name of the underlying board,like "goldfish". |
String |
BOOTLOADER |
The system bootloader version number. |
String |
BRAND |
The brand (e.g.,carrier) the software is customized for,if any. |
String |
CPU_ABI |
The name of the instruction set (CPU type + ABI convention) of native code. |
String |
CPU_ABI2 |
The name of the second instruction set (CPU type + ABI convention) of native code. |
String |
DEVICE |
The name of the industrial design. |
String |
DISPLAY |
A build ID string meant for displaying to the user |
String |
FINGERPRINT |
A string that uniquely identifies this build. |
String |
HARDWARE |
The name of the hardware (from the kernel command line or /proc). |
String |
HOST |
? |
String |
ID |
Either a changelist number,or a label like "M4-rc20". |
String |
MANUFACTURER |
The manufacturer of the product/hardware. |
String |
MODEL |
The end-user-visible name for the end product. |
String |
PRODUCT |
The name of the overall product. |
String |
RADIO |
The radio firmware version number. |
String |
SERIAL |
A hardware serial number,if available. |
String |
TAGS |
Comma-separated tags describing the build,like "unsigned,debug". |
long |
TIME |
? |
String |
TYPE |
The type of build,like "user" or "eng". |
String |
UNKNOWN |
Value used for when a build property is unknown. |
String |
USER |
获取手机屏幕高度:
[java]?
view plain
copy
print
?
- private?void?getWeithAndHeight(){????
- ????????????//这种方式在service中无法使用,????
- ????????????DisplayMetrics?dm?=?new?DisplayMetrics();????
- ????????????getWindowManager().getDefaultDisplay().getMetrics(dm);????
- ????????????String?width?=?dm.widthPixels;??????????????//宽????
- ????????????String?height?=?dm.heightPixels;???????????//高????
- ?????????
- ????????????//在service中也能得到高和宽????
- ????????????WindowManager?mWindowManager?=?(WindowManager)?getSystemService(Context.WINDOW_SERVICE);????
- ????????????width?=?mWindowManager.getDefaultDisplay().getWidth();????
- ????????????height?=?mWindowManager.getDefaultDisplay().getHeight();????
- ????????}??
获取手机MAC地址:
[java]?
view plain
copy
print
?
- private?String?getMacAddress(){????
- ?????????????String?result?=?"";????
- ?????????????WifiManager?wifiManager?=?(WifiManager)?getSystemService(Context.WIFI_SERVICE);????
- ?????????????WifiInfo?wifiInfo?=?wifiManager.getConnectionInfo();????
- ?????????????result?=?wifiInfo.getMacAddress();????
- ?????????????Log.i(TAG,?"macAdd:"?+?result);????
- ?????????????return?result;????
- ?????}??
手机CPU信息
[java]?
view plain
copy
print
?
- private?String[]?getCpuInfo()?{????
- ?????????????String?str1?=?"/proc/cpuinfo";????
- ?????????????String?str2?=?"";????
- ?????????????String[]?cpuInfo?=?{"",?""};??//1-cpu型号??//2-cpu频率????
- ?????????????String[]?arrayOfString;????
- ?????????????try?{????
- ?????????????????FileReader?fr?=?new?FileReader(str1);????
- ?????????????????BufferedReader?localBufferedReader?=?new?BufferedReader(fr,?8192);????
- ?????????????????str2?=?localBufferedReader.readLine();????
- ?????????????????arrayOfString?=?str2.split("s+");????
- ?????????????????for?(int?i?=?2;?i?<?arrayOfString.length;?i++)?{????
- ?????????????????????cpuInfo[]?=?cpuInfo[]?+?arrayOfString[i]?+?"?";????
- ?????????????????}????
- ?????????????????str2?=?localBufferedReader.readLine();????
- ?????????????????arrayOfString?=?str2.split("s+");????
- ?????????????????cpuInfo[1]?+=?arrayOfString[2];????
- ?????????????????localBufferedReader.close();????
- ?????????????}?catch?(IOException?e)?{????
- ?????????????}????
- ?????????????Log.i(TAG,?"cpuinfo:"?+?cpuInfo[]?+?"?"?+?cpuInfo[1]);????
- ?????????????return?cpuInfo;????
- ?????????}??
获取手机可用内存和总内存:
[java]?
view plain
copy
print
?
- private?String[]?getTotalMemory()?{????
- ????????????String[]?result?=?{"",""};??//1-total?2-avail????
- ????????????ActivityManager.MemoryInfo?mi?=?new?ActivityManager.MemoryInfo();??????
- ????????????mActivityManager.getMemoryInfo(mi);??????
- ????????????long?mTotalMem?=?;????
- ????????????long?mAvailMem?=?mi.availMem;????
- ????????????String?str1?=?"/proc/meminfo";????
- ????????????String?str2;????
- ????????????String[]?arrayOfString;????
- ????????????try?{????
- ????????????????FileReader?localFileReader?=?new?FileReader(str1);????
- ????????????????BufferedReader?localBufferedReader?=?new?BufferedReader(localFileReader,?8192);????
- ????????????????str2?=?localBufferedReader.readLine();????
- ????????????????arrayOfString?=?str2.split("s+");????
- ????????????????mTotalMem?=?Integer.valueOf(arrayOfString[1]).intValue()?*?1024;????
- ????????????????localBufferedReader.close();????
- ????????????}?catch?(IOException?e)?{????
- ????????????????e.printStackTrace();????
- ????????????}????
- ????????????result[]?=?Formatter.formatFileSize(this,?mTotalMem);????
- ????????????result[1]?=?Formatter.formatFileSize(this,?mAvailMem);????
- ????????????Log.i(TAG,?"meminfo?total:"?+?result[]?+?"?used:"?+?result[1]);????
- ????????????return?result;????
- ????????}??
获取手机安装的应用信息(排除系统自带):
[java]?
view plain
copy
print
?
- private?String?getAllApp()?{????
- ?????????????String?result?=?"";????
- ?????????????List<PackageInfo>?packages?=?getPackageManager().getInstalledPackages();????
- ?????????????for?(PackageInfo?i?:?packages)?{????
- ?????????????????if?((i.applicationInfo.flags?&?ApplicationInfo.FLAG_SYSTEM)?==?)?{????
- ?????????????????????result?+=?i.applicationInfo.loadLabel(getPackageManager()).toString()?+?",";????
- ?????????????????}????
- ?????????????}????
- ?????????????return?result.substring(,?result.length()?-?1);????
- ?????}??
-