Using System.getProperty(“os.arch”) to check if it is armeabi cpu

吃可爱长大的小学妹 提交于 2019-12-05 08:53:14

The method System.getProperty is a generic method of Java, here you can find the documentation.

On Linux it returns the same value obtained from the command uname -m. The possible values are for example armv5t, armv5te, armv5tej, armv5tejl, armv6, armv7, armv7l, i686 and many more. There isn't an exact value for the armeabi devices because it slightly differs from cpu to cpu.

There is a better alternative to System.getProperty and it is the field Build.CPU_ABI (or Build.SUPPORTED_ABIS in newer devices):

String abi = null;

if (Build.VERSION.SDK_INT < Build.VERSION_CODES.LOLLIPOP) {
    abi = Build.CPU_ABI;
} else {
    abi = Build.SUPPORTED_ABIS[0];
}

The possible values are armeabi, armeabi-v7a, arm64-v8a, x86, x86_64, mips, mips64.

As you can see the number of possible results is much lower than System.getProperty, and you can check directly for armeabi.

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!