is On Emulator - Android Android OS

Android examples for Android OS:Emulator

Description

is On Emulator

Demo Code

/**//w w  w . j  a v  a 2  s .  c o  m
 * KTH Developed by Java
 *
 * @Copyright 2011 by Service Platform Development Team, KTH, Inc. All rights reserved.
 *
 * This software is the confidential and proprietary information of KTH, Inc.
 * You shall not disclose such Confidential Information and shall use it only
 * in accordance with the terms of the license agreement you entered into with KTH.
 */
//package com.java2s;

import android.content.ContentResolver;
import android.content.Context;

import android.os.Build;

public class Main {
    private static final String EMULATOR_ID = "ffffffffffffffff";

    public static boolean isOnEmulator(Context context) {
        if ("sdk".equals(Build.MODEL) && "sdk".equals(Build.PRODUCT)) {
            return true;
        }
        return getUniqueDeviceID(context).equals(EMULATOR_ID);
    }

    public static String getUniqueDeviceID(Context context) {
        ContentResolver contentResolver = context.getContentResolver();
        String id = android.provider.Settings.System.getString(
                contentResolver,
                android.provider.Settings.System.ANDROID_ID);
        if (id == null)
            id = EMULATOR_ID;
        return id;
    }
}

Related Tutorials