2011-11-11

在 Android 區別 Emulator 與真正的手機

有時候在開發環境想要用不同的設定或寫法,試了一些方法去辨別:
String androidId = Secure.getString(this.getContentResolver(),
        Secure.ANDROID_ID);
Log.d(TAG, "andoridId: " + androidId);
Log.d(TAG, "BOARD: " + Build.BOARD);
Log.d(TAG, "BOOTLOADER: " + Build.BOOTLOADER);
Log.d(TAG, "BRAND: " + Build.BRAND);
Log.d(TAG, "CPU_ABI: " + Build.CPU_ABI);
Log.d(TAG, "CPU_ABI2: " + Build.CPU_ABI2);
Log.d(TAG, "DEVICE: " + Build.DEVICE);
Log.d(TAG, "DISPLAY: " + Build.DISPLAY);
Log.d(TAG, "FINGERPRINT: " + Build.FINGERPRINT);
Log.d(TAG, "HARDWARE: " + Build.HARDWARE);
Log.d(TAG, "HOST: " + Build.HOST);
Log.d(TAG, "ID: " + Build.ID);
Log.d(TAG, "MANUFACTURER: " + Build.MANUFACTURER);
Log.d(TAG, "MODEL: " + Build.MODEL);
Log.d(TAG, "PRODUCT: " + Build.PRODUCT);
Log.d(TAG, "RADIO: " + Build.RADIO);
Log.d(TAG, "SERIAL: " + Build.SERIAL);
Log.d(TAG, "TAGS: " + Build.TAGS);
Log.d(TAG, "TIME: " + Build.TIME);
Log.d(TAG, "TYPE: " + Build.TYPE);
Log.d(TAG, "UNKNOWN: " + Build.UNKNOWN);
Log.d(TAG, "USER: " + Build.USER);
以下是幾個版本在 Emulator 執行的結果:

Version 1.6

Version 2.2

Version 2.3.1

Version 2.3.3

可以從官方解釋找到一些機會:


Manufacturer 都是 unknown,Model 與 Product 都是 sdk。

沒有留言:

張貼留言