1、最简单的是使用Build的信息。
import android.os.Build;
String cpu = Build.CPU_ABI;cpu.startWith("arm");
2、使用系统文件/proc/cpuinfo
1. try {
2. new FileInputStream("/proc/cpuinfo");
3. new InputStreamReader(is);
4. new BufferedReader(ir);
5. try {
6. "Processor";
7. "Features";
8. "model name";
9. "cpu family";
10. while (true) {
11. String line = br.readLine();
12. null;
13. if (line == null) {
14. break;
15. }
16. ":");
17. if (pair.length != 2)
18. continue;
19. 0].trim();
20. 1].trim();
21. if (key.compareTo(nameProcessor) == 0) {
22. "";
23. for (int i = val.indexOf("ARMv") + 4; i < val.length(); i++) {
24. "";
25. if (temp.matches("\\d")) {
26. n += temp;
27. else {
28. break;
29. }
30. }
31. 0] = "ARM";
32. 1] = Integer.parseInt(n);
33. continue;
34. }
35.
36. if (key.compareToIgnoreCase(nameFeatures) == 0) {
37. if (val.contains("neon")) {
38. 2] = "neon";
39. }
40. continue;
41. }
42.
43. if (key.compareToIgnoreCase(nameModel) == 0) {
44. if (val.contains("Intel")) {
45. 0] = "INTEL";
46. 2] = "atom";
47. }
48. continue;
49. }
50.
51. if (key.compareToIgnoreCase(nameCpuFamily) == 0) {
52. 1] = Integer.parseInt(val);
53. continue;
54. }
55. }
56. finally {
57. br.close();
58. ir.close();
59. is.close();
60. }
61. catch (Exception e) {
62. e.printStackTrace();
63. }