下面是编程之家 jb51.cc 通过网络收集整理的代码片段。
编程之家小编现在分享给大家,也给大家做个参考。
IMEI号,IESI号,手机型号:
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 |
获取手机屏幕高度:
- 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地址:
- 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信息
- 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;
- }
获取手机可用内存和总内存:
- 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;
- }
获取手机安装的应用信息(排除系统自带):
- 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);
- }
-
以上是编程之家(jb51.cc)为你收集整理的全部代码内容,希望文章能够帮你解决所遇到的程序开发问题。
如果觉得编程之家网站内容还不错,欢迎将编程之家网站推荐给程序员好友。