This article will talk about how to using Java code to detect device.
Please kindly use ro.product.cpu.abilist and check every entry in it.
recommand "getprop ro.product.cpu.abilist", which will return x86 or x86_64 for intel architecture devices.
Sample code
try {
Process process = Runtime.getRuntime().exec("getprop ro.product.cpu.abilist");
InputStreamReader ir = new InputStreamReader(process.getInputStream());
BufferedReader input = new BufferedReader(ir);
final String abilist = input.readLine();
if (!abilist.isEmpty()) {
final String[] abi = abilist.split(",");
if(abi[0].contains("x86_64")) {
Log.i("mytag", "abi x86_64: " + abi[0]);
} else if (abi[0].contains("x86")) {
Log.i("mytag", "abi x86: " + abi[0]);
} else if (abi[0].contains("armeabi-v7a")) {
Log.i("mytag", "abi armeabi-v7a: " + abi[0]);
} else if (abi[0].contains("armeabi")) {
Log.i("mytag", "abi armeabi: " + abi[0]);
} else if (abi[0].contains("arm64-v8a")) {
Log.i("mytag", "abi arm64-v8a: " + abi[0]);
} else {
Log.i("mytag", "abi unknown: " + abi[0]);
}
} else {
Log.i("mytag", "abilist is empty");
}
} catch (IOException e) {
e.printStackTrace();
}
then now you can know which device is it, and do some customization or optimization trick.
图标图像:
Clik here to view.
