Example usage for android.os Build BRAND

List of usage examples for android.os Build BRAND

Introduction

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

Prototype

String BRAND

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

Click Source Link

Document

The consumer-visible brand with which the product/hardware will be associated, if any.

Usage

From source file:name.setup.dance.DanceStepApp.java

/** Called when the activity is first created. */
@Override//from  w w w  .j a va2s  .c  o  m
public void onCreate(Bundle savedInstanceState) {
    Log.i(TAG, "[ACTIVITY] onCreate");
    super.onCreate(savedInstanceState);

    //mStepValue = 0;
    mPaceValue = 0;

    setContentView(R.layout.main);

    mUtils = Utils.getInstance();

    String m_szDevIDShort = "35" + //we make this look like a valid IMEI
            Build.BOARD.length() % 10 + Build.BRAND.length() % 10 + Build.CPU_ABI.length() % 10
            + Build.DEVICE.length() % 10 + Build.DISPLAY.length() % 10 + Build.HOST.length() % 10
            + Build.ID.length() % 10 + Build.MANUFACTURER.length() % 10 + Build.MODEL.length() % 10
            + Build.PRODUCT.length() % 10 + Build.TAGS.length() % 10 + Build.TYPE.length() % 10
            + Build.USER.length() % 10; //13 digits

    mUtils.DeviceName = m_szDevIDShort;

    Log.v(TAG, "ID: " + m_szDevIDShort);
    Log.v(TAG, "UTILS: " + mUtils.DeviceName);

    // user name
    mTextField = (EditText) findViewById(R.id.name_area);
    mTextField.setCursorVisible(false);

    if (!(mUtils.UserName == "My Name")) {

        mTextField.setText(mUtils.UserName);
    }
    mTextField.setOnClickListener(new View.OnClickListener() {
        public void onClick(View v) {
            // Perform action on click

            InputMethodManager mgr = (InputMethodManager) getSystemService(Context.INPUT_METHOD_SERVICE);
            // only will trigger it if no physical keyboard is open
            mgr.showSoftInput(mTextField, InputMethodManager.SHOW_IMPLICIT);

            mTextField.requestFocus();
            mTextField.setCursorVisible(true);
            mOkayButton.setVisibility(View.VISIBLE);

        }

    });

    // init okay Button
    mOkayButton = (Button) findViewById(R.id.okay_button);
    mOkayButton.setVisibility(View.INVISIBLE);
    mOkayButton.setOnClickListener(new View.OnClickListener() {
        public void onClick(View v) {
            // Perform action on click
            InputMethodManager mgr = (InputMethodManager) getSystemService(Context.INPUT_METHOD_SERVICE);
            mgr.hideSoftInputFromWindow(getWindow().getCurrentFocus().getWindowToken(), 0);

            mTextField.setCursorVisible(false);
            mTextField.clearFocus();
            mUtils.UserName = mTextField.getText().toString();

            // post name via HHTP
            new Thread(new Runnable() {
                public void run() {
                    if (mIsMetric) {
                        postHTTP(mUtils.DeviceName, mUtils.UserName, mStepValue, mDistanceValue);
                    } else {
                        postHTTP(mUtils.DeviceName, mUtils.UserName, mStepValue, mDistanceValue * 1.609344f);
                    }
                }
            }).start();
            mOkayButton.setVisibility(View.INVISIBLE);

            // Post TOAST MESSAGE
            Toast.makeText(getApplicationContext(), getText(R.string.name_saved), Toast.LENGTH_SHORT).show();

        }

    });

    // init Score Button
    mScoreButton = (Button) findViewById(R.id.scoreButton);
    mScoreButton.setOnClickListener(new View.OnClickListener() {
        public void onClick(View v) {
            // Perform action on click
            String url = "http://www.setup.nl/tools/dancestep_app/index.php?id=" + mUtils.DeviceName + "&time="
                    + System.currentTimeMillis();
            Intent i = new Intent(Intent.ACTION_VIEW);
            i.setData(Uri.parse(url));
            startActivity(i);
        }
    });

}

From source file:io.kristal.appinfos.AppInfosPlugin.java

private synchronized static String getUniqueId(Context context) {
    String uniqueID = null;//from  www  . j  ava2 s  . co m
    SharedPreferences sharedPrefs = context.getSharedPreferences(PREF_UNIQUE_ID, Context.MODE_PRIVATE);
    uniqueID = sharedPrefs.getString(PREF_UNIQUE_ID, null);
    if (uniqueID == null) {
        uniqueID = Settings.Secure.getString(context.getContentResolver(), Settings.Secure.ANDROID_ID);
        if (uniqueID == null || uniqueID.length() == 0 || "9774d56d682e549c".equals(uniqueID)) {
            // old version of reto meier
            //uniqueID = UUID.randomUUID().toString();
            uniqueID = "35" + //we make this look like a valid IMEI
                    Build.BOARD.length() % 10 + Build.BRAND.length() % 10 + Build.CPU_ABI.length() % 10
                    + Build.DEVICE.length() % 10 + Build.DISPLAY.length() % 10 + Build.HOST.length() % 10
                    + Build.ID.length() % 10 + Build.MANUFACTURER.length() % 10 + Build.MODEL.length() % 10
                    + Build.PRODUCT.length() % 10 + Build.TAGS.length() % 10 + Build.TYPE.length() % 10
                    + Build.USER.length() % 10; //13 digits
        }
        SharedPreferences.Editor editor = sharedPrefs.edit();
        editor.putString(PREF_UNIQUE_ID, uniqueID);
        editor.commit();
    }
    return uniqueID;
}

From source file:conversandroid.RichASR.java

/**
 * Creates the speech recognizer instance if it is available
 * *///  w w w.ja  va 2s .c  om
public void initASR() {

    // find out whether speech recognition is supported
    List<ResolveInfo> intActivities = this.getPackageManager()
            .queryIntentActivities(new Intent(RecognizerIntent.ACTION_RECOGNIZE_SPEECH), 0);

    //Speech recognition does not currently work on simulated devices
    if ("generic".equals(Build.BRAND.toLowerCase())) {
        Log.e(LOGTAG, "ASR is not supported on virtual devices");
    } else {
        if (intActivities.size() != 0) {
            myASR = SpeechRecognizer.createSpeechRecognizer(getApplicationContext());
            myASR.setRecognitionListener(this);
        }
    }

    Log.i(LOGTAG, "ASR initialized");
}

From source file:com.tencent.wetest.common.util.DeviceUtil.java

/**
 * ??/*  w w  w.j  a va  2  s  . co  m*/
 * @param context 
 * @return DeviceInfoJSON?
 */
public static String getDeviceInfo(Context context) {

    try {

        JSONArray content_f_Device = new JSONArray();
        JSONObject manu = new JSONObject();
        manu.put("manu", android.os.Build.BRAND);
        content_f_Device.put(manu);

        JSONObject model = new JSONObject();
        model.put("model", android.os.Build.MODEL);
        content_f_Device.put(model);

        JSONObject version = new JSONObject();
        version.put("version", getVersion(context));
        content_f_Device.put(version);

        JSONObject cpu = new JSONObject();
        cpu.put("cpu", "" + getCpuCoreNum());
        content_f_Device.put(cpu);

        JSONObject mem = new JSONObject();
        mem.put("mem", "" + getTotalMemory(context));
        content_f_Device.put(mem);

        JSONObject resolution = new JSONObject();
        resolution.put("resolution", "" + getDisplayMetrics(context));
        content_f_Device.put(resolution);

        JSONObject cpufreq = new JSONObject();
        cpufreq.put("cpufreq", getCpuMaxFreq());
        content_f_Device.put(cpufreq);
        //+","+getCpuMinFreq()

        JSONObject cpuname = new JSONObject();
        cpuname.put("cpuname", getCpuName());
        content_f_Device.put(cpuname);

        return content_f_Device.toString();

    } catch (JSONException e) {

        Logger.error("getDeviceInfo Exception : " + e.toString());

    }

    return null;
}

From source file:de.schildbach.wallet.util.CrashReporter.java

public static void appendDeviceInfo(final Appendable report, final Context context) throws IOException {
    final Resources res = context.getResources();
    final android.content.res.Configuration config = res.getConfiguration();
    final ActivityManager activityManager = (ActivityManager) context
            .getSystemService(Context.ACTIVITY_SERVICE);
    final DevicePolicyManager devicePolicyManager = (DevicePolicyManager) context
            .getSystemService(Context.DEVICE_POLICY_SERVICE);

    report.append("Device Model: " + Build.MODEL + "\n");
    report.append("Android Version: " + Build.VERSION.RELEASE + "\n");
    if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.M)
        report.append("Android security patch level: ").append(Build.VERSION.SECURITY_PATCH).append("\n");
    report.append("ABIs: ").append(Joiner.on(", ").skipNulls().join(Strings.emptyToNull(Build.CPU_ABI),
            Strings.emptyToNull(Build.CPU_ABI2))).append("\n");
    report.append("Board: " + Build.BOARD + "\n");
    report.append("Brand: " + Build.BRAND + "\n");
    report.append("Device: " + Build.DEVICE + "\n");
    report.append("Display: " + Build.DISPLAY + "\n");
    report.append("Finger Print: " + Build.FINGERPRINT + "\n");
    report.append("Host: " + Build.HOST + "\n");
    report.append("ID: " + Build.ID + "\n");
    report.append("Product: " + Build.PRODUCT + "\n");
    report.append("Tags: " + Build.TAGS + "\n");
    report.append("Time: " + Build.TIME + "\n");
    report.append("Type: " + Build.TYPE + "\n");
    report.append("User: " + Build.USER + "\n");
    report.append("Configuration: " + config + "\n");
    report.append("Screen Layout: size "
            + (config.screenLayout & android.content.res.Configuration.SCREENLAYOUT_SIZE_MASK) + " long "
            + (config.screenLayout & android.content.res.Configuration.SCREENLAYOUT_LONG_MASK) + "\n");
    report.append("Display Metrics: " + res.getDisplayMetrics() + "\n");
    report.append("Memory Class: " + activityManager.getMemoryClass() + "/"
            + activityManager.getLargeMemoryClass()
            + (ActivityManagerCompat.isLowRamDevice(activityManager) ? " (low RAM device)" : "") + "\n");
    report.append("Storage Encryption Status: " + devicePolicyManager.getStorageEncryptionStatus() + "\n");
    report.append("Bluetooth MAC: " + bluetoothMac() + "\n");
    report.append("Runtime: ").append(System.getProperty("java.vm.name")).append(" ")
            .append(System.getProperty("java.vm.version")).append("\n");
}

From source file:atlc.granadaaccessibilityranking.VoiceActivity.java

/**
 * Creates the speech recognizer and text-to-speech synthesizer instances
 * @see RecognitionListener.java// ww  w  .j a  v  a 2  s  . com
 * @param ctx context of the interaction
 * */
public void initSpeechInputOutput(Activity ctx) {

    this.ctx = ctx;
    PackageManager packManager = ctx.getPackageManager();

    setTTS();

    // Find out whether speech recognition is supported
    List<ResolveInfo> intActivities = packManager
            .queryIntentActivities(new Intent(RecognizerIntent.ACTION_RECOGNIZE_SPEECH), 0);
    if (intActivities.size() != 0 || "generic".equals(Build.BRAND.toLowerCase(Locale.US))) {
        myASR = SpeechRecognizer.createSpeechRecognizer(ctx);
        myASR.setRecognitionListener(this);
    } else
        myASR = null;
}

From source file:org.cook_e.cook_e.BugReportActivity.java

/**
 * Gathers information about the device running the application and returns it as a JSONObject
 * @return information about the system/*  w  w w. ja v  a2s  .  co m*/
 */
private JSONObject getSystemInformation() {
    final JSONObject json = new JSONObject();

    try {
        final JSONObject build = new JSONObject();
        build.put("version_name", BuildConfig.VERSION_NAME);
        build.put("version_code", BuildConfig.VERSION_CODE);
        build.put("build_type", BuildConfig.BUILD_TYPE);
        build.put("debug", BuildConfig.DEBUG);

        json.put("build", build);

        final JSONObject device = new JSONObject();
        device.put("board", Build.BOARD);
        device.put("bootloader", Build.BOOTLOADER);
        device.put("brand", Build.BRAND);
        device.put("device", Build.DEVICE);
        device.put("display", Build.DISPLAY);
        device.put("fingerprint", Build.FINGERPRINT);
        device.put("hardware", Build.HARDWARE);
        device.put("host", Build.HOST);
        device.put("id", Build.ID);
        device.put("manufacturer", Build.MANUFACTURER);
        device.put("model", Build.MODEL);
        device.put("product", Build.PRODUCT);
        device.put("radio", Build.getRadioVersion());
        device.put("serial", Build.SERIAL);
        device.put("tags", Build.TAGS);
        device.put("time", Build.TIME);
        device.put("type", Build.TYPE);
        device.put("user", Build.USER);

        json.put("device", device);
    } catch (JSONException e) {
        // Ignore
    }

    return json;
}

From source file:com.scvngr.levelup.core.net.RequestUtilsTest.java

/**
 * Helper method to get the device specific portion of the user agent screen.
 *
 * @return device specific part of the user agent string
 *///from ww  w .ja  v  a 2 s  . com
private static String getDeviceSpecificUserAgentString() {
    return String.format(Locale.US, " (Linux; U; Android %s; %s/%s; %s)", Build.VERSION.RELEASE, Build.BRAND,
            Build.PRODUCT, Locale.getDefault().toString());
}

From source file:edu.rutgers.winlab.crowdpp.ui.MainActivity.java

public void onCreate(Bundle savedInstanceState) {
    super.onCreate(savedInstanceState);
    setContentView(R.layout.main_activity_layout);

    // Create the adapter that will return a fragment for each of the three primary sections of the app.
    mAppSectionsPagerAdapter = new AppSectionsPagerAdapter(getSupportFragmentManager());

    // Set up the action bar.
    final ActionBar actionBar = getActionBar();

    // Specify that the Home/Up button should not be enabled, since there is no hierarchical parent.
    actionBar.setHomeButtonEnabled(false);

    // Specify that we will be displaying tabs in the action bar.
    actionBar.setNavigationMode(ActionBar.NAVIGATION_MODE_TABS);

    // Set up the ViewPager, attaching the adapter and setting up a listener for when the user swipes between sections.
    mViewPager = (ViewPager) findViewById(R.id.pager);
    mViewPager.setAdapter(mAppSectionsPagerAdapter);
    mViewPager.setOnPageChangeListener(new ViewPager.SimpleOnPageChangeListener() {
        @Override//from  w w w . j a  v  a 2 s .c  om
        public void onPageSelected(int position) {
            // When swiping between different app sections, select the corresponding tab.
            // We can also use ActionBar.Tab#select() to do this if we have a reference to the Tab.
            actionBar.setSelectedNavigationItem(position);
        }
    });

    // For each of the sections in the app, add a tab to the action bar.
    for (int i = 0; i < mAppSectionsPagerAdapter.getCount(); i++) {
        // Create a tab with text corresponding to the page title defined by the adapter.
        // Also specify this Activity object, which implements the TabListener interface, as the listener for when this tab is selected.
        actionBar.addTab(
                actionBar.newTab().setText(mAppSectionsPagerAdapter.getPageTitle(i)).setTabListener(this));
    }

    SharedPreferences settings = this.getSharedPreferences("config", Context.MODE_PRIVATE);
    ;
    SharedPreferences.Editor editor = settings.edit();

    // load the default parameters into SharedPreferences for the first time launch 
    int ct = settings.getInt("count", 0);
    if (ct == 0) {
        editor.putString("start", "9");
        editor.putString("end", "21");
        editor.putString("interval", "15");
        editor.putString("duration", "5");
        editor.putString("location", "On");
        editor.putString("upload", "On");
        TelephonyManager tm = (TelephonyManager) getSystemService(Context.TELEPHONY_SERVICE);
        editor.putString("IMEI", tm.getDeviceId());
        editor.putString("brand", Build.BRAND);
        editor.putString("model", Build.MODEL);
        String phone_type = Build.BRAND + "_" + Build.MODEL;

        // motoX
        if (phone_type.equals("motorola_XT1058")) {
            editor.putString("mfcc_dist_same_semi", "13");
            editor.putString("mfcc_dist_diff_semi", "18");
            editor.putString("mfcc_dist_same_un", "13");
            editor.putString("mfcc_dist_diff_un", "18");
        }
        // nexus 4
        else if (phone_type.equals("google_Nexus 4")) {
            editor.putString("mfcc_dist_same_semi", "17");
            editor.putString("mfcc_dist_diff_semi", "22");
            editor.putString("mfcc_dist_same_un", "17");
            editor.putString("mfcc_dist_diff_un", "22");
        }
        // s2
        else if (phone_type.equals("samsung_SAMSUNG-SGH-I727")) {
            editor.putString("mfcc_dist_same_semi", "18");
            editor.putString("mfcc_dist_diff_semi", "25");
            editor.putString("mfcc_dist_same_un", "18");
            editor.putString("mfcc_dist_diff_un", "25");
        }
        // s3 
        else if (phone_type.equals("samsung_SAMSUNG-SGH-I747")) {
            editor.putString("mfcc_dist_same_semi", "16");
            editor.putString("mfcc_dist_diff_semi", "21");
            editor.putString("mfcc_dist_same_un", "16");
            editor.putString("mfcc_dist_diff_un", "21");
        }
        // s4
        else if (phone_type.equals("samsung_SAMSUNG-SGH-I337")) {
            editor.putString("mfcc_dist_same_semi", "14");
            editor.putString("mfcc_dist_diff_semi", "24");
            editor.putString("mfcc_dist_same_un", "14");
            editor.putString("mfcc_dist_diff_un", "24");
        }
        // other devices
        else {
            editor.putString("mfcc_dist_same_semi", "15.6");
            editor.putString("mfcc_dist_diff_semi", "21.6");
            editor.putString("mfcc_dist_same_un", "15.6");
            editor.putString("mfcc_dist_diff_un", "21.6");
            Toast.makeText(this, "Your device is not recognized and the result might not be accurate...",
                    Toast.LENGTH_SHORT).show();
        }
        Log.i("Crowd++", "First time launched");

        AlertDialog dialog = new AlertDialog.Builder(this).create();
        dialog.setTitle("Welcome to Crowd++");
        dialog.setMessage(Constants.hello_msg);
        dialog.setButton(AlertDialog.BUTTON_POSITIVE, "Close", new DialogInterface.OnClickListener() {
            @Override
            public void onClick(DialogInterface dialog, int which) {

            }
        });
        dialog.show();
        dialog.getButton(DialogInterface.BUTTON_POSITIVE).setTextSize(20);
    }

    editor.putInt("count", ++ct);
    editor.commit();
    Log.i("Launched Count", Integer.toString(ct));
    mConst = new Constants(this);
    if (!Constants.calibration())
        Toast.makeText(this, "You haven't calibrated the system.", Toast.LENGTH_SHORT).show();
}

From source file:com.example.feedback.ActivityMain.java

/**
 * Get device information and save to application cache to send as attachment in feedback email.
 *///from www .ja va2 s  .  co m
public void getDeviceInfo() {
    try {
        dateTime = new Date();
        timeFormat = new SimpleDateFormat("yyyy-MM-dd HH:mm:ss.SSS", Locale.US);

        packageInfo = getPackageManager().getPackageInfo(getPackageName(), 0);
        appName = getApplicationContext().getString(packageInfo.applicationInfo.labelRes);
        appVersion = packageInfo.versionName;
        appCode = Integer.toString(packageInfo.versionCode);

        // Get application information.
        stringInfo = "date/time: " + timeFormat.format(dateTime) + "\n\n";
        stringInfo += "packageName: " + packageInfo.packageName + "\n";
        stringInfo += "packageCode: " + appCode + "\n";
        stringInfo += "packageVersion: " + appVersion + "\n";

        // Get network information.
        telephonyManager = ((TelephonyManager) getApplicationContext()
                .getSystemService(Context.TELEPHONY_SERVICE));

        if (!telephonyManager.getNetworkOperatorName().equals("")) {
            stringInfo += "operatorNetName: " + telephonyManager.getNetworkOperatorName() + "\n";
        } else if (!telephonyManager.getSimOperatorName().equals("")) {
            stringInfo += "operatorSimName: " + telephonyManager.getSimOperatorName() + "\n";
        }

        // Get device information.
        stringInfo += "Build.MODEL: " + Build.MODEL + "\n";
        stringInfo += "Build.BRAND: " + Build.BRAND + "\n";
        stringInfo += "Build.DEVICE: " + Build.DEVICE + "\n";
        stringInfo += "Build.PRODUCT: " + Build.PRODUCT + "\n";
        stringInfo += "Build.ID: " + Build.ID + "\n";
        stringInfo += "Build.TYPE: " + Build.TYPE + "\n";
        stringInfo += "Build.VERSION.SDK_INT: " + Build.VERSION.SDK_INT + "\n";
        stringInfo += "Build.VERSION.RELEASE: " + Build.VERSION.RELEASE + "\n";
        stringInfo += "Build.VERSION.INCREMENTAL: " + Build.VERSION.INCREMENTAL + "\n";
        stringInfo += "Build.VERSION.CODENAME: " + Build.VERSION.CODENAME + "\n";
        stringInfo += "Build.BOARD: " + Build.BOARD + "\n\n";

        // Get other application information.
        activityManager = (ActivityManager) this.getSystemService(ACTIVITY_SERVICE);
        runningProcesses = activityManager.getRunningAppProcesses();
        runningApplications = "";

        for (ActivityManager.RunningAppProcessInfo runningProcess : runningProcesses) {
            runningApplications += "\n  " + runningProcess.processName;
        }

        stringInfo += "Applications running:" + runningApplications;

        // Save information to cached file.
        fileOutput = new FileOutputStream(getCacheDir().getAbsolutePath() + "/deviceInfo.log");
        fileOutput.write(stringInfo.getBytes());
        fileOutput.close();
    } catch (Exception e) {
    }
}