Android代码中判断当前App是否为64位


/**
 * 当前App是否为64位
 *
 * @param context 上下文
 * @return 当前App为64位返回true,反之返回false
 */
public static boolean isApp64BitAbi(Context context) {
    try {
        String nativeLibraryDir = context.getApplicationInfo().nativeLibraryDir;
        int nextIndexOfLastSlash = nativeLibraryDir.lastIndexOf('/') + 1;
        String instructionSet = nativeLibraryDir.substring(nextIndexOfLastSlash);
        return "arm64".equals(instructionSet) || "x86_64".equals(instructionSet) || "mips64".equals(instructionSet);
    } catch (Exception x) {
        Log.e(TAG, "isApp64BitAbi error=" + x);
    }
    return false;
}

猜你喜欢

转载自blog.csdn.net/chenzhengfeng/article/details/131410176
今日推荐