How to know a process of an app is 32-bit or 64-bi

2020-07-10 07:29发布

As we all know from Android 5.0.64bit support is there. I have very simple question. Can we check programmatically in what mode any application is running i.e. 32bit or 64bit? For example: I have Facebook app running on my Nexus 9, so can I check using my android app if Facebook app's process is running in 32bit mode or 64bit mode?

Thanks in advance!

3条回答
太酷不给撩
2楼-- · 2020-07-10 08:06

Try System.getProperty("os.arch"). I haven't tried it on 64-bit android, but it must return something like 'aarch64' in case of 64 bit device.

http://developer.android.com/reference/java/lang/System.html#getProperty(java.lang.String)

查看更多
一纸荒年 Trace。
3楼-- · 2020-07-10 08:13

In Nexus 5x

String arch = System.getProperty("os.arch");

returns

armv8l

it is not aarch64 and my code broke. However,

root@bullhead:/ # uname -m
aarch64

root@bullhead:/ # getprop ro.product.cpu.abilist
arm64-v8a,armeabi-v7a,armeabi

Wired. So I changed my code to

boolean is64 = (android.os.Build.VERSION.SDK_INT >= 21) && System.getProperty("ro.product.cpu.abilist").contains("64");

Updated on 2016-02-11

In Samsung Samsung Galaxy S5 Neo, Android 5.1.1

String arch = System.getProperty("os.arch");

returns aarch64 but it is not 64-bit device!!!

ro.product.cpu.abilist returns armeabi-v7a,armeabi

bool is64Bit =   System.getProperty("ro.product.cpu.abilist").contains("64");

check is the only way to check.

查看更多
神经病院院长
4楼-- · 2020-07-10 08:23

What makes you think your device isn't 64-bit? The specs for the phone indicate it uses an Exynos 7 Octa 7580 which is arm8 and 64-bit.

查看更多
登录 后发表回答