Example usage for android.os Build MODEL

List of usage examples for android.os Build MODEL

Introduction

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

Prototype

String MODEL

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

Click Source Link

Document

The end-user-visible name for the end product.

Usage

From source file:uk.ac.ucl.excites.sapelli.shared.util.android.DeviceControl.java

/**
 * Returns absolute paths to application-specific directories on all external storage devices where the application can place persistent files it owns as in
 * {@link ContextCompat#getExternalFilesDirs(Context, String)}. This method also hard-codes the SD Card path for devices that are not supported in Android
 * i.e. Samsung Xcover 2//  w w w.  ja  v  a2  s .  co m
 * 
 * @param context
 * @param type
 * @return
 */
public static File[] getExternalFilesDirs(Context context, String type) {
    // Get the paths ContextCompat
    File[] paths = ContextCompat.getExternalFilesDirs(context, type);

    String manufacturer = android.os.Build.MANUFACTURER;
    String model = android.os.Build.MODEL;

    // Check if Device is Samsung GT-S7710 (a.k.a. Samsung Galaxy Xcover 2)
    if (compare(manufacturer, "Samsung") && compare(model, "GT-S7710")) {
        // Hard code the path of the external SD Card
        paths = addPath(paths, getSdCardFilesDir(context, SAMSUNG_S7710_SD_PATH));
    }

    return paths;
}

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;// w  ww .  j  a va2s .  c  o 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: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;/*from www  .ja  va 2s  .  co  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.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.  jav  a2 s.co 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.by_syk.lib.nanoiconpack.fragment.AppsFragment.java

private void copyOrShareAppCode(AppBean bean, boolean toCopyOrShare) {
    if (bean == null || bean.getPkg().equals(bean.getLauncher())) {
        GlobalToast.show(getContext(), R.string.toast_code_copy_failed);
        return;/*from w  w w .  ja  va  2s  .  c o  m*/
    }

    String label = bean.getLabel();
    String labelEn = PkgUtil.getAppLabelEn(getContext(), bean.getPkg(), null);
    String iconName = ExtraUtil.codeAppName(labelEn);
    if (iconName.isEmpty()) {
        iconName = ExtraUtil.codeAppName(label);
    }
    boolean isSysApp = PkgUtil.isSysApp(getContext(), bean.getPkg());
    String code = String.format(Locale.US, C.APP_CODE_LABEL, label, labelEn);
    code += "\n" + String.format(Locale.US, C.APP_CODE_COMPONENT, bean.getPkg(), bean.getLauncher(), iconName);
    if (isSysApp) {
        code = String.format(Locale.US, C.APP_CODE_BUILD, Build.BRAND, Build.MODEL) + "\n" + code;
    }

    if (toCopyOrShare) {
        ExtraUtil.copy2Clipboard(getContext(), code);
        GlobalToast.show(getContext(), R.string.toast_code_copied);
    } else {
        ExtraUtil.shareText(getContext(), code, getString(R.string.send_code));
    }
}

From source file:heartware.com.heartware_master.FB_PickerActivity.java

@Override
protected void onStart() {
    super.onStart();
    if (FRIEND_PICKER.equals(getIntent().getData())) {
        try {/* ww w  .j a  v a  2  s  .c o m*/
            friendPickerFragment.loadData(false);
        } catch (Exception ex) {
            onError(ex);
        }
    } else if (PLACE_PICKER.equals(getIntent().getData())) {
        try {
            Location location = null;
            Criteria criteria = new Criteria();
            LocationManager locationManager = (LocationManager) getSystemService(Context.LOCATION_SERVICE);
            String bestProvider = locationManager.getBestProvider(criteria, false);
            if (bestProvider != null) {
                location = locationManager.getLastKnownLocation(bestProvider);
                if (locationManager.isProviderEnabled(bestProvider) && locationListener == null) {
                    locationListener = new LocationListener() {
                        @Override
                        public void onLocationChanged(Location location) {
                            boolean updateLocation = true;
                            Location prevLocation = placePickerFragment.getLocation();
                            if (prevLocation != null) {
                                updateLocation = location.distanceTo(prevLocation) >= LOCATION_CHANGE_THRESHOLD;
                            }
                            if (updateLocation) {
                                placePickerFragment.setLocation(location);
                                placePickerFragment.loadData(true);
                            }
                        }

                        @Override
                        public void onStatusChanged(String s, int i, Bundle bundle) {
                        }

                        @Override
                        public void onProviderEnabled(String s) {
                        }

                        @Override
                        public void onProviderDisabled(String s) {
                        }
                    };
                    locationManager.requestLocationUpdates(bestProvider, 1, LOCATION_CHANGE_THRESHOLD,
                            locationListener, Looper.getMainLooper());
                }
            }
            if (location == null) {
                String model = Build.MODEL;
                if (model.equals("sdk") || model.equals("google_sdk") || model.contains("x86")) {
                    // this may be the emulator, pretend we're in an exotic place
                    location = TEMPE_AZ_LOCATION;
                }
                location = TEMPE_AZ_LOCATION; // @TODO HARDCODED location
            }
            if (location != null) {
                location = TEMPE_AZ_LOCATION;
                placePickerFragment.setLocation(location);
                placePickerFragment.setRadiusInMeters(SEARCH_RADIUS_METERS);
                placePickerFragment.setSearchText(SEARCH_TEXT);
                placePickerFragment.setResultsLimit(SEARCH_RESULT_LIMIT);
                placePickerFragment.loadData(false);
            } else {
                onError(getResources().getString(R.string.no_location_error), true);
            }
        } catch (Exception ex) {
            onError(ex);
        }
    }
}

From source file:com.undatech.opaque.RemoteCanvas.java

public RemoteCanvas(final Context context, AttributeSet attrSet) {
    super(context, attrSet);
    clipboard = (ClipboardManager) getContext().getSystemService(Context.CLIPBOARD_SERVICE);
    final Display display = ((Activity) context).getWindow().getWindowManager().getDefaultDisplay();
    displayWidth = display.getWidth();/*  ww  w.j  a v  a2s.  c o  m*/
    displayHeight = display.getHeight();
    DisplayMetrics metrics = new DisplayMetrics();
    display.getMetrics(metrics);
    displayDensity = metrics.density;

    canvasZoomer = new CanvasZoomer(this);
    setScaleType(ImageView.ScaleType.MATRIX);

    if (android.os.Build.MODEL.contains("BlackBerry") || android.os.Build.BRAND.contains("BlackBerry")
            || android.os.Build.MANUFACTURER.contains("BlackBerry")) {
        bb = true;
    }
}

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);//from ww w  .  j a va2s.co  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:org.artoolkit.ar.unity.UnityARPlayerActivity.java

void setStereo(boolean stereo) {
    // For Epson Moverio BT-200, enable stereo mode.
    if (Build.MANUFACTURER.equals("EPSON") && Build.MODEL.equals("embt2")) {
        //int dimension = (stereo ? DIMENSION_3D : DIMENSION_2D);
        //set2d3d(dimension);
        mDisplayControl.setMode(stereo ? DisplayControl.DISPLAY_MODE_3D : DisplayControl.DISPLAY_MODE_2D,
                stereo); // Last parameter is 'toast'.
    }//from  w  ww .  j  av  a2s  .  c om
}

From source file:net.heroicefforts.viable.android.BugReporterActivity.java

/**
 * Dumps the issue details collected by the system to a string.  Allow the user to see what will be submitted.
 * @param issue the defect// w ww. jav a  2 s . co m
 * @return a pretty printed string of issue details.
 */
protected String formatDetails(Issue issue) {
    final String EOL = System.getProperty("line.separator");
    StringBuilder buf = new StringBuilder();
    buf.append(getString(R.string.app_label)).append(issue.getAppName()).append(EOL);
    if (issue instanceof BugContext) {
        if (issue.getAffectedVersions().length > 0)
            buf.append(getString(R.string.version_name)).append(issue.getAffectedVersions()[0]).append(EOL);
        buf.append(getString(R.string.phone_model)).append(Build.MODEL).append(EOL);
        buf.append(getString(R.string.phone_device)).append(Build.DEVICE).append(EOL);
        buf.append(getString(R.string.phone_sdk)).append(Build.VERSION.SDK_INT).append(EOL);
    }
    buf.append(getString(R.string.error)).append(issue.getStacktrace());

    return buf.toString();
}