Checks whether or not the running device is an emulator. - Android Android OS

Android examples for Android OS:System Model

Description

Checks whether or not the running device is an emulator.

Demo Code

/**// w  w w  .ja v a2  s .  c o  m
 * AdFlakeUtil.java (AdFlakeSDK-Android)
 *
 * Copyright ? 2013 MADE GmbH - All Rights Reserved.
 *
 * Unauthorized copying of this file, via any medium is strictly prohibited
 * unless otherwise noted in the License section of this document header.
 *
 * @file AdFlakeUtil.java
 * @copyright 2013 MADE GmbH. All rights reserved.
 * @section License
 * Licensed under the Apache License, Version 2.0 (the "License");
 * you may not use this file except in compliance with the License.
 * You may obtain a copy of the License at
 *
 * http://www.apache.org/licenses/LICENSE-2.0
 *
 * Unless required by applicable law or agreed to in writing, software
 * distributed under the License is distributed on an "AS IS" BASIS,
 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
 * See the License for the specific language governing permissions and
 * limitations under the License.
 */
//package com.java2s;

import android.os.Build;

public class Main {
    /**
     * Checks whether or not the running device is an emulator.
     * 
     * @return Boolean indicating if the app is currently running in an
     *         emulator.
     */
    public static boolean isEmulator() {
        return (Build.BOARD.equals("unknown")
                && Build.DEVICE.equals("generic") && Build.BRAND
                    .equals("generic"));
    }
}

Related Tutorials