Example usage for android.os Build DEVICE

List of usage examples for android.os Build DEVICE

Introduction

In this page you can find the example usage for android.os Build DEVICE.

Prototype

String DEVICE

To view the source code for android.os Build DEVICE.

Click Source Link

Document

The name of the industrial design.

Usage

From source file:com.cc.signalinfo.fragments.SignalFragment.java

/**
 * Set the phone model, OS version, carrier name on the screen
 *//* ww  w.  jav  a  2s  . c o m*/
private void setPhoneInfo() {
    setTextViewText(R.id.deviceName, String.format("%s %s", Build.MANUFACTURER, Build.MODEL));
    setTextViewText(R.id.deviceModel, String.format("%s/%s (%s) ", Build.PRODUCT, Build.DEVICE, Build.ID));
    setTextViewText(R.id.androidVersion, String.format(activity.getString(R.string.androidVersion),
            Build.VERSION.RELEASE, Build.VERSION.SDK_INT));

    setTextViewText(R.id.carrierName, tm.getNetworkOperatorName());
    setTextViewText(R.id.buildHost, Build.HOST);
    setNetworkTypeText();
}

From source file:jahirfiquitiva.iconshowcase.utilities.Utils.java

public static void sendEmailWithDeviceInfo(Context context) {
    StringBuilder emailBuilder = new StringBuilder();
    Intent intent = new Intent(Intent.ACTION_VIEW,
            Uri.parse("mailto:" + context.getResources().getString(R.string.email_id)));
    intent.putExtra(Intent.EXTRA_SUBJECT, context.getResources().getString(R.string.email_subject));
    emailBuilder.append("\n \n \nOS Version: ").append(System.getProperty("os.version")).append("(")
            .append(Build.VERSION.INCREMENTAL).append(")");
    emailBuilder.append("\nOS API Level: ").append(Build.VERSION.SDK_INT);
    emailBuilder.append("\nDevice: ").append(Build.DEVICE);
    emailBuilder.append("\nManufacturer: ").append(Build.MANUFACTURER);
    emailBuilder.append("\nModel (and Product): ").append(Build.MODEL).append(" (").append(Build.PRODUCT)
            .append(")");
    PackageInfo appInfo = null;//from w w  w.jav a2s  .  c  o  m
    try {
        appInfo = context.getPackageManager().getPackageInfo(context.getPackageName(), 0);
    } catch (PackageManager.NameNotFoundException e) {
        e.printStackTrace();
    }
    assert appInfo != null;
    emailBuilder.append("\nApp Version Name: ").append(appInfo.versionName);
    emailBuilder.append("\nApp Version Code: ").append(appInfo.versionCode);
    intent.putExtra(Intent.EXTRA_TEXT, emailBuilder.toString());
    context.startActivity(
            Intent.createChooser(intent, (context.getResources().getString(R.string.send_title))));
}

From source file:com.architjn.materialicons.ui.MainActivity.java

@Override
public boolean onOptionsItemSelected(MenuItem item) {
    // Handle action bar item clicks here. The action bar will
    // automatically handle clicks on the Home/Up button, so long
    // as you specify a parent activity in AndroidManifest.xml.
    int id = item.getItemId();

    //noinspection SimplifiableIfStatement
    if (id == R.id.action_sendemail) {
        StringBuilder emailBuilder = new StringBuilder();

        Intent intent = new Intent(Intent.ACTION_VIEW,
                Uri.parse("mailto:" + getResources().getString(R.string.email_id)));
        intent.putExtra(Intent.EXTRA_SUBJECT, getResources().getString(R.string.email_subject));

        emailBuilder.append("\n \n \nOS Version: ").append(System.getProperty("os.version")).append("(")
                .append(Build.VERSION.INCREMENTAL).append(")");
        emailBuilder.append("\nOS API Level: ").append(Build.VERSION.SDK_INT);
        emailBuilder.append("\nDevice: ").append(Build.DEVICE);
        emailBuilder.append("\nManufacturer: ").append(Build.MANUFACTURER);
        emailBuilder.append("\nModel (and Product): ").append(Build.MODEL).append(" (").append(Build.PRODUCT)
                .append(")");
        PackageInfo appInfo = null;//from  w  w w  .  j  a v a 2  s . c  o  m
        try {
            appInfo = getPackageManager().getPackageInfo(getPackageName(), 0);
        } catch (PackageManager.NameNotFoundException e) {
            e.printStackTrace();
        }
        assert appInfo != null;
        emailBuilder.append("\nApp Version Name: ").append(appInfo.versionName);
        emailBuilder.append("\nApp Version Code: ").append(appInfo.versionCode);

        intent.putExtra(Intent.EXTRA_TEXT, emailBuilder.toString());
        startActivity(Intent.createChooser(intent, (getResources().getString(R.string.send_title))));
        return true;
    } else if (id == R.id.action_share) {
        Intent sharingIntent = new Intent(Intent.ACTION_SEND);
        sharingIntent.setType("text/plain");
        String shareBody = getResources().getString(R.string.share_one)
                + getResources().getString(R.string.developer_name)
                + getResources().getString(R.string.share_two) + MARKET_URL + getPackageName();
        sharingIntent.putExtra(Intent.EXTRA_TEXT, shareBody);
        startActivity(Intent.createChooser(sharingIntent, (getResources().getString(R.string.share_title))));
    } else if (id == R.id.action_changelog) {
        showChangelog();
    }

    return super.onOptionsItemSelected(item);
}

From source file:com.jahirfiquitiva.paperboard.activities.Main.java

@Override
public boolean onOptionsItemSelected(MenuItem item) {
    super.onOptionsItemSelected(item);

    switch (item.getItemId()) {
    case R.id.share:
        Intent sharingIntent = new Intent(Intent.ACTION_SEND);
        sharingIntent.setType("text/plain");
        String shareBody = "Check out this awesome icon pack by "
                + getResources().getString(R.string.iconpack_designer) + ".    Download Here: "
                + getResources().getString(R.string.play_store_link);
        sharingIntent.putExtra(Intent.EXTRA_TEXT, shareBody);
        startActivity(Intent.createChooser(sharingIntent, (getResources().getString(R.string.share_title))));
        break;//  w  ww.  j  a v  a  2 s .c o m

    case R.id.sendemail:
        StringBuilder emailBuilder = new StringBuilder();

        Intent intent = new Intent(Intent.ACTION_VIEW,
                Uri.parse("mailto:" + getResources().getString(R.string.email_id)));
        intent.putExtra(Intent.EXTRA_SUBJECT, getResources().getString(R.string.email_subject));

        emailBuilder.append("\n \n \nOS Version: " + System.getProperty("os.version") + "("
                + Build.VERSION.INCREMENTAL + ")");
        emailBuilder.append("\nOS API Level: " + Build.VERSION.SDK_INT);
        emailBuilder.append("\nDevice: " + Build.DEVICE);
        emailBuilder.append("\nManufacturer: " + Build.MANUFACTURER);
        emailBuilder.append("\nModel (and Product): " + Build.MODEL + " (" + Build.PRODUCT + ")");
        PackageInfo appInfo = null;
        try {
            appInfo = getPackageManager().getPackageInfo(getPackageName(), 0);
        } catch (PackageManager.NameNotFoundException e) {
            e.printStackTrace();
        }
        emailBuilder.append("\nApp Version Name: " + appInfo.versionName);
        emailBuilder.append("\nApp Version Code: " + appInfo.versionCode);

        intent.putExtra(Intent.EXTRA_TEXT, emailBuilder.toString());
        startActivity(Intent.createChooser(intent, (getResources().getString(R.string.send_title))));
        break;

    case R.id.changelog:
        changelog();
        break;
    }
    return true;
}

From source file:com.tdispatch.passenger.core.TDApplication.java

@SuppressWarnings("deprecation")
protected void initEnvInfo() {

    DisplayMetrics dm = getResources().getDisplayMetrics();

    String orientation = "???";
    switch (getResources().getConfiguration().orientation) {
    case Configuration.ORIENTATION_LANDSCAPE:
        orientation = "Landscape";
        break;/*  ww  w. j  a v  a 2 s  .co  m*/
    case Configuration.ORIENTATION_PORTRAIT:
        orientation = "Portrait";
        break;
    case Configuration.ORIENTATION_SQUARE:
        orientation = "Square";
        break;
    case Configuration.ORIENTATION_UNDEFINED:
        orientation = "Undef";
        break;
    default:
        orientation = "Unknown";
        break;
    }

    try {
        mEnvInfoJson.put("type", isTablet() ? "tablet" : "phone");
        mEnvInfoJson.put("build_manufacturer", Build.MANUFACTURER);
        mEnvInfoJson.put("build_model", Build.MODEL);
        mEnvInfoJson.put("build_board", Build.BOARD);
        mEnvInfoJson.put("build_device", Build.DEVICE);
        mEnvInfoJson.put("build_product", Build.PRODUCT);
        mEnvInfoJson.put("api", Build.VERSION.SDK_INT + " (" + Build.VERSION.RELEASE + ")");
        mEnvInfoJson.put("screen",
                dm.widthPixels + "x" + dm.heightPixels + " (" + dm.densityDpi + "DPI) " + orientation);

        mEnvInfoJson.put("locale", Locale.getDefault());
    } catch (Exception e) {
        e.printStackTrace();
    }
}

From source file:de.ub0r.android.lib.DonationHelper.java

/**
 * Get MD5 hash of the IMEI (device id).
 * /* ww  w  .j a v  a  2s . c  om*/
 * @param context
 *            {@link Context}
 * @return MD5 hash of IMEI
 */
public static String getImeiHash(final Context context) {
    if (imeiHash == null) {
        // get imei
        TelephonyManager mTelephonyMgr = (TelephonyManager) context.getSystemService(Context.TELEPHONY_SERVICE);
        final String did = mTelephonyMgr.getDeviceId();
        if (did != null) {
            imeiHash = Utils.md5(did);
        } else {
            imeiHash = Utils.md5(Build.BOARD + Build.BRAND + Build.PRODUCT + Build.DEVICE);
        }
    }
    return imeiHash;
}

From source file:com.prt.thirdeye.CamManager.java

/**
 * Opens the camera and show its preview in the preview
 * //w w  w .j a v a  2 s .  co m
 * @param cameraId
 *            The facing of the camera
 * @return true if the operation succeeded, false otherwise
 */
@SuppressLint("NewApi")
public boolean open(final int cameraId) {
    if (mCamera != null) {
        if (mPreviewPauseListener != null) {
            mPreviewPauseListener.onPreviewPause();
        }

        // Close the previous camera
        releaseCamera();
    }

    mCameraReady = false;

    // Try to open the camera
    new Thread() {
        public void run() {
            try {
                if (mCamera != null) {
                    Log.e(TAG, "Previous camera not closed! Not opening");
                    return;
                }

                mCamera = Camera.open(cameraId);
                Log.v(TAG, "Camera is open");

                if (Build.VERSION.SDK_INT >= 17) {
                    mCamera.enableShutterSound(false);
                }
                mCamera.setPreviewCallback(mPreview);
                mCurrentFacing = cameraId;
                mParameters = mCamera.getParameters();

                if (DEBUG_LOG_PARAMS) {
                    String params = mCamera.getParameters().flatten();
                    final int step = params.length() > 256 ? 256 : params.length();
                    for (int i = 0; i < params.length(); i += step) {
                        Log.d(TAG, params);
                        params = params.substring(step);
                    }
                }

                // Mako hack to raise FPS
                if (Build.DEVICE.equals("mako")) {
                    Camera.Size maxSize = mParameters.getSupportedPictureSizes().get(0);
                    mParameters.setPictureSize(maxSize.width, maxSize.height);
                }

                if (mAutoFocusMoveCallback != null) {
                    setAutoFocusMoveCallback(mAutoFocusMoveCallback);
                }
            } catch (Exception e) {
                Log.e(TAG, "Error while opening cameras: " + e.getMessage(), e);

                if (mCameraReadyListener != null) {
                    mCameraReadyListener.onCameraFailed();
                }

                return;
            }

            // Update the preview surface holder with the new opened camera
            mPreview.notifyCameraChanged(false);

            if (mCameraReadyListener != null) {
                mCameraReadyListener.onCameraReady();
            }
            if (mPreviewPauseListener != null) {
                mPreviewPauseListener.onPreviewResume();
            }

            mPreview.setPauseCopyFrame(false);

            mCameraReady = true;
        }
    }.start();

    return true;
}

From source file:com.mobilyzer.util.PhoneUtils.java

/**
 * Returns a string representing this phone:
 *
 * "Android_<hardware-type>-<build-release>_<network-type>_" +
 * "<network-carrier>_<mobile-type>_<Portrait-or-Landscape>"
 *
 * hardware-type is e.g. "dream", "passion", "emulator", etc.
 * build-release is the SDK public release number e.g. "2.0.1" for Eclair.
 * network-type is e.g. "Wifi", "Edge", "UMTS", "3G".
 * network-carrier is the mobile carrier name if connected via the SIM card,
 *     or the Wi-Fi SSID if connected via the Wi-Fi.
 * mobile-type is the phone's mobile network connection type -- "GSM" or "CDMA".
 *
 * If the device screen is currently in lanscape mode, "_Landscape" is
 * appended at the end./* w w  w .  j  a v  a2  s.c o m*/
 *
 * TODO(klm): This needs to be converted into named URL args from positional,
 * both here and in the iPhone app. Otherwise it's hard to add extensions,
 * especially if there is optional stuff like
 *
 * @return a string representing this phone
 */
public String generatePhoneId() {
    String device = Build.DEVICE.equals("generic") ? "emulator" : Build.DEVICE;
    String network = getNetwork();
    String carrier = (network == NETWORK_WIFI) ? getWifiCarrierName() : getTelephonyCarrierName();

    StringBuilder stringBuilder = new StringBuilder(ANDROID_STRING);
    stringBuilder.append('-').append(device).append('_').append(Build.VERSION.RELEASE).append('_')
            .append(network).append('_').append(carrier).append('_').append(getTelephonyPhoneType()).append('_')
            .append(isLandscape() ? "Landscape" : "Portrait");

    return stringBuilder.toString();
}

From source file:com.google.mist.plot.MainActivity.java

private void dumpSensorData() throws JSONException { //TODO(cjr): do we want JSONException here?
    File dataDir = getOrCreateSessionDir();
    File target = new File(dataDir, String.format("%s.json", mRecordingType));

    JSONObject jsonObject = new JSONObject();
    jsonObject.put("version", "1.0.0");

    boolean isCalibrated = mPullDetector.getCalibrationStatus();
    jsonObject.put("calibrated", isCalibrated);

    // Write system information
    Display display = getWindowManager().getDefaultDisplay();
    Point size = new Point();
    display.getSize(size);// w w  w .  j  av a 2s .  c  o m
    JSONObject deviceData = new JSONObject();
    deviceData.put("Build.DEVICE", Build.DEVICE);
    deviceData.put("Build.MODEL", Build.MODEL);
    deviceData.put("Build.PRODUCT", Build.PRODUCT);
    deviceData.put("Build.VERSION.SDK_INT", Build.VERSION.SDK_INT);
    deviceData.put("screenResolution.X", size.x);
    deviceData.put("screenResolution.Y", size.y);
    jsonObject.put("systemInfo", deviceData);

    // Write magnetometer data
    JSONArray magnetData = new JSONArray();
    for (int i = 0; i < mSensorData.size(); i++) {
        JSONArray dataPoint = new JSONArray();
        long time = mSensorTime.get(i);
        dataPoint.put(time);
        dataPoint.put(mSensorAccuracy.get(i));
        float[] data = mSensorData.get(i);
        for (float d : data) {
            dataPoint.put(d);
        }
        magnetData.put(dataPoint);
    }
    jsonObject.put("magnetometer", magnetData);

    // Write onAccuracyChanged data
    JSONArray accuracyChangedData = new JSONArray();
    for (int i = 0; i < mAccuracyData.size(); i++) {
        JSONArray dataPoint = new JSONArray();
        long time = mAccuracyTime.get(i);
        dataPoint.put(time);
        dataPoint.put(mAccuracyData.get(i));
        accuracyChangedData.put(dataPoint);
    }
    jsonObject.put("onAccuracyChangedData", accuracyChangedData);

    // Write rotation data
    if (mRecordRotation) {
        JSONArray rotationData = new JSONArray();
        for (int i = 0; i < mSensorData.size(); i++) {
            JSONArray dataPoint = new JSONArray();
            long time = mRotationTime.get(i);
            dataPoint.put(time);
            float[] data = mRotationData.get(i);
            for (float d : data) {
                dataPoint.put(d);
            }
            rotationData.put(dataPoint);
        }
        jsonObject.put("rotation", rotationData);
    }

    // Write event labels
    JSONArray trueLabels = new JSONArray();
    for (int i = 0; i < mPositivesData.size(); i++) {
        JSONArray dataPoint = new JSONArray();
        long time = mPositivesTime.get(i);
        dataPoint.put(time);
        dataPoint.put(mPositivesData.get(i));
        trueLabels.put(dataPoint);
    }
    jsonObject.put("labels", trueLabels);

    try {
        FileWriter fw = new FileWriter(target, true);
        fw.write(jsonObject.toString());
        fw.flush();
        fw.close();
        mDumpPath = target.toString();
    } catch (IOException e) {
        Log.e(TAG, e.toString());
    }
}

From source file:com.ktouch.kdc.launcher4.camera.CameraManager.java

/**
 * Opens the camera and show its preview in the preview
 *
 * @param cameraId The facing of the camera
 * @return true if the operation succeeded, false otherwise
 *//*ww w.  jav a  2  s . com*/
public boolean open(final int cameraId) {
    if (mCamera != null) {
        if (mPreviewPauseListener != null) {
            mPreviewPauseListener.onPreviewPause();
        }

        // Close the previous camera
        releaseCamera();
    }

    mCameraReady = false;

    // Try to open the camera
    new Thread() {
        public void run() {
            try {
                if (DEBUG_PROFILER)
                    Profiler.getDefault().start("CameraOpen");
                if (mCamera != null) {
                    Log.e(TAG, "Previous camera not closed! Not opening");
                    return;
                }

                mCamera = Camera.open(cameraId);
                Log.v(TAG, "Camera is open");

                if (Build.VERSION.SDK_INT >= 17) {
                    mCamera.enableShutterSound(false);
                }
                mCamera.setPreviewCallback(mPreview);
                mCurrentFacing = cameraId;
                mParameters = mCamera.getParameters();

                if (DEBUG_LOG_PARAMS) {
                    String params = mCamera.getParameters().flatten();
                    final int step = params.length() > 256 ? 256 : params.length();
                    for (int i = 0; i < params.length(); i += step) {
                        Log.d(TAG, params);
                        params = params.substring(step);
                    }
                }

                // Mako hack to raise FPS
                if (Build.DEVICE.equals("mako")) {
                    Camera.Size maxSize = mParameters.getSupportedPictureSizes().get(0);
                    mParameters.setPictureSize(maxSize.width, maxSize.height);
                }

                if (mAutoFocusMoveCallback != null) {
                    setAutoFocusMoveCallback(mAutoFocusMoveCallback);
                }
            } catch (Exception e) {
                Log.e(TAG, "Error while opening cameras: " + e.getMessage(), e);

                if (mCameraReadyListener != null) {
                    mCameraReadyListener.onCameraFailed();
                }

                return;
            }

            // Update the preview surface holder with the new opened camera
            mPreview.notifyCameraChanged(false);

            if (mCameraReadyListener != null) {
                mCameraReadyListener.onCameraReady();
            }
            if (mPreviewPauseListener != null) {
                mPreviewPauseListener.onPreviewResume();
            }

            mPreview.setPauseCopyFrame(false);

            mCameraReady = true;
            if (DEBUG_PROFILER)
                Profiler.getDefault().logProfile("CameraOpen");
        }
    }.start();

    return true;
}