有一定的NDK编程基础的同学都知道,在C++层面可以使用android_getCpuFamily()获取CPU的ABI架构。那么,有没有不依赖NDK的获取ABI呢?有,总共有两种方法
1、方法一
private String cpuinfo(){String arch = System.getProperty("os.arch"); String arc = arch.substring(0, 3).toUpperCase();String rarc="";if (arc.equals("ARM")) { rarc= "This is ARM"; }else if (arc.equals("MIP")){ rarc= "This is MIPS"; }else if (arc.equals("X86")){ rarc= "This is X86"; } return rarc;}
方法二:
String abi = null;if (Build.VERSION.SDK_INT < Build.VERSION_CODES.LOLLIPOP) { abi = Build.CPU_ABI;} else { abi = Build.SUPPORTED_ABIS[0];}