CPU support ARM v7a - Android Hardware

Android examples for Hardware:CPU Information

Description

CPU support ARM v7a

Demo Code


//package com.book2s;
import java.lang.reflect.Field;
import android.os.Build;
import android.text.TextUtils;

public class Main {
    public static final String ABI_ARMv7a = "armeabi-v7a";

    public static boolean supportARMv7a() {
        return supportABI(ABI_ARMv7a);
    }/*from  w w  w  .  ja  v  a2s .c om*/

    public static boolean supportABI(String requestAbi) {
        String abi = get_CPU_ABI();
        if (!TextUtils.isEmpty(abi) && abi.equalsIgnoreCase(requestAbi))
            return true;

        String abi2 = get_CPU_ABI2();
        if (!TextUtils.isEmpty(abi2) && abi.equalsIgnoreCase(requestAbi))
            return true;

        return false;
    }

    public static final String get_CPU_ABI() {
        return Build.CPU_ABI;
    }

    public static final String get_CPU_ABI2() {
        try {
            Field field = Build.class.getDeclaredField("CPU_ABI2");
            if (field == null)
                return null;

            Object fieldValue = field.get(null);
            if (field == null || !(fieldValue instanceof String)) {
                return null;
            }

            return (String) fieldValue;
        } catch (Exception e) {

        }

        return null;
    }
}

Related Tutorials