android的新手 - 如何检测正在使用哪种手机?

时间:2013-09-14 18:28:01

标签: android

我需要知道手机是否是星系2或冰淇淋,因为我必须编写一些代码来解决它们中的错误。

我试图查看一些文档,但找不到任何东西......有人可以提供一些帮助吗?

2 个答案:

答案 0 :(得分:0)

使用以下代码获取有关设备的所有信息,并检查其Galaxy Note2或检查sdk版本,看看它的冰淇淋或Kitkat:P

        String Info3 = android.os.Build.VERSION.RELEASE;
        String Info4 = android.os.Build.DEVICE; 
        String Info5 = android.os.Build.MODEL; 
        String Info6 = android.os.Build.PRODUCT; 
        String Info7 = android.os.Build.BRAND; 
        String Info8 = android.os.Build.DISPLAY; 
        String Info9 = android.os.Build.CPU_ABI; 
        String Info10 = android.os.Build.CPU_ABI2; 
        String Info11 = android.os.Build.UNKNOWN; 
        String Info12 = android.os.Build.HARDWARE;
        String Info13 = android.os.Build.ID; 
        String Info14 = android.os.Build.MANUFACTURER; 
        String Info15 = android.os.Build.SERIAL; 
        String Info16 = android.os.Build.USER; 
        String Info2 = System.getProperty("os.version");
        String Info17 = android.os.Build.HOST; 

http://developer.android.com/reference/android/os/Build.html

的更多信息

答案 1 :(得分:0)

您有太多详细信息

    /**
     * @TelePhonyManager: for telephony related details some permission like CoarseLocation, PhoneState are neccessary to get some Telephony Details
     */

    String telephonyInfo = "", buildInfo = "", deviceId, cellLocation, deviceSoftwareVersion, number, networkOperatorIso, networkOperatorName, NetworkType, PhoneType, simOperatorISO, simOperatorName, simSerialNumber, subscriberId, voiceMailNumber, isNetworkRoaming;
    try
    {
        TelephonyManager tm =
                (TelephonyManager) mContext
                        .getSystemService(Context.TELEPHONY_SERVICE);
        GsmCellLocation gcl =
                (GsmCellLocation) tm
                        .getCellLocation();
        gcl.requestLocationUpdate();

        deviceId = "";
        cellLocation = "";
        telephonyInfo =
                "TelephonyInfo \n\tCellLocation_CID_LAC_PSC_MCCMNC ="
                        +
                        String.valueOf(gcl
                                .getCid()
                                + "_"
                                + gcl.getLac()
                                + "_"
                                + gcl.getPsc()) + String.valueOf(tm.getNetworkOperator())
                        + "\n\tDeviceId ="
                        +
                        String.valueOf(tm
                                .getDeviceId())
                        + "\n\tDviceSoftwareVersion ="
                        +
                        String.valueOf(tm
                                .getDeviceSoftwareVersion())
                        + "\n\tNumber ="
                        +
                        String.valueOf(tm
                                .getLine1Number())
                        + "\n\tNetworkOperatorIso ="
                        +
                        String.valueOf(
                                tm.getNetworkCountryIso())
                                .toUpperCase()
                        + "\n\tNetworkOperatorName ="
                        +
                        String.valueOf(tm
                                .getNetworkOperatorName())
                        + "\n\tNetworkType ="
                        +
                        String.valueOf(tm
                                .getNetworkType())
                        +
                        "\n\tPhoneType ="
                        +
                        String.valueOf(tm
                                .getPhoneType())
                        + "\n\tSimOperatorISO ="
                        +
                        String.valueOf(
                                tm.getSimCountryIso())
                                .toUpperCase()
                        + "\n\tSimOperatorName ="
                        +
                        String.valueOf(
                                tm.getSimOperatorName())
                                .toUpperCase()
                        + "\n\tSimSerialNumber ="
                        +
                        String.valueOf(tm
                                .getSimSerialNumber())
                        + "\n\tSubscriberId ="
                        +
                        String.valueOf(tm
                                .getSubscriberId())
                        + "\n\tVoiceMailNumber ="
                        +
                        String.valueOf(tm
                                .getVoiceMailNumber())
                        + "\n\tIsNetworkRoaming ="
                        +
                        String.valueOf(tm
                                .isNetworkRoaming());
    }
    catch(Exception e)
    {       
    }
    /*
     * BuildVersion Related Detials
     */

    try
    {
        buildInfo =
                "Build\n\t BOARD="
                        + Build.BOARD
                        + "\n\t BOOTLOADER="
                        + Build.BOOTLOADER
                        + "\n\t BRAND="
                        + Build.BRAND
                        + "\n\t CPU_ABI="
                        + Build.CPU_ABI
                        + "\n\t CPU_ABI2="
                        + Build.CPU_ABI2
                        + "\n\t DEVICE="
                        + Build.DEVICE
                        + "\n\t DISPLAY="
                        + Build.DISPLAY
                        + "\n\t FINGERPRINT="
                        + Build.FINGERPRINT
                        + "\n\t HARDWARE="
                        + Build.HARDWARE
                        + "\n\t HOST="
                        + Build.HOST
                        + "\n\t ID="
                        + Build.ID
                        + "\n\t MANUFACTURER="
                        + Build.MANUFACTURER
                        + "\n\t MODEL="
                        + Build.MODEL
                        + "\n\t PRODUCT="
                        + Build.PRODUCT
                        + "\n\t SERIAL="
                        + Build.SERIAL
                        + "\n\t TAGS="
                        + Build.TAGS
                        + "\n\t TIME="
                        + Build.TIME
                        + "\n\t TYPE="
                        + Build.TYPE
                        + "\n\t UNKNOWN="
                        + Build.UNKNOWN
                        + "\n\t USER="
                        + Build.USER
                        + "\n\n\nBuild.VERSION \n\tVERSION.CodeName="
                        + Build.VERSION.CODENAME
                        + "\n\t VERSION.INCREMENTAL= "
                        + Build.VERSION.INCREMENTAL
                        + "\n\t VERSION.RELEASE= "
                        + Build.VERSION.RELEASE
                        + "\n\t VERSION.SDK_INT= "
                        + Build.VERSION.SDK_INT;
    }
    catch(Exception e)
    {}