CPU support ABI - Android Hardware

Android examples for Hardware:CPU Information

Description

CPU support ABI

Demo Code


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

public class Main {
    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;
    }/*ww  w. ja  v a 2  s  . com*/

    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