Android代码获取android手机是32位还是64位
时间: 2024-03-17 19:42:36 浏览: 8
您可以通过以下代码获取Android手机是32位还是64位:
```java
public static String getSystemProperty(String propName) {
String line;
BufferedReader input = null;
try {
Process p = Runtime.getRuntime().exec("getprop " + propName);
input = new BufferedReader(new InputStreamReader(p.getInputStream()), 1024);
line = input.readLine();
input.close();
} catch (IOException ex) {
return null;
} finally {
if (input != null) {
try {
input.close();
} catch (IOException e) {
}
}
}
return line;
}
public static boolean is64Bit() {
String value = getSystemProperty("ro.product.cpu.abi");
return value != null && value.contains("64");
}
```
其中,is64Bit() 方法返回一个 boolean 值,用于判断当前设备是不是64位设备。如果返回 true,则表示当前设备是64位设备;如果返回 false,则表示当前设备是32位设备。