How to detect android device is 64 bit or 32 bit processor?

Tùng Phan Thanh picture Tùng Phan Thanh · Sep 8, 2015 · Viewed 25.8k times · Source

I'm trying to find a best solution for this question. The reason is the lib in our application can not run with the 64 bit processor so I need to turn it off in this case. I found that in Android version 21 (lolipop)and higher we can easily detect that the device is 32 bit or 64 bit processor by using Build.SUPPORTED_64_BIT_ABIS and if It returns the String array with 0 elements then... a hah! The device is 32 bit processor. How about lower android version? Build.SUPPORTED_64_BIT_ABIS just only support from android Lolipop version and higher. Thanks & Best Regards, Wish you guys all the best!

Answer

kakopappa picture kakopappa · Jan 21, 2016
 try {
            boolean  isArm64 = false;

            BufferedReader localBufferedReader = new BufferedReader(new FileReader("/proc/cpuinfo"));
            if (localBufferedReader.readLine().contains("aarch64")) {
                isArm64 = true;
            }
            localBufferedReader.close();
        } catch (IOException e) {
        }

Or

final boolean is64bit = Build.SUPPORTED_64_BIT_ABIS.length > 0;