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:com.stoutner.privacybrowser.AboutTabFragment.java

@Override
public View onCreateView(LayoutInflater inflater, ViewGroup container, Bundle savedInstanceState) {
    View tabLayout;//ww w .  j a v  a 2s  .c  o  m

    // Load the about tab layout.  Tab numbers start at 0.
    if (tabNumber == 0) {
        // Setting false at the end of inflater.inflate does not attach the inflated layout as a child of container.
        // The fragment will take care of attaching the root automatically.
        tabLayout = inflater.inflate(R.layout.about_tab_version, container, false);

        // Version.
        TextView versionNumberText = (TextView) tabLayout.findViewById(R.id.about_version_number_text);
        String version = getString(R.string.version) + " " + BuildConfig.VERSION_NAME + " ("
                + getString(R.string.version_code) + " " + Integer.toString(BuildConfig.VERSION_CODE) + ")";
        versionNumberText.setText(version);

        // Brand.
        TextView versionBrandText = (TextView) tabLayout.findViewById(R.id.about_version_brand_text);
        versionBrandText.setText(Build.BRAND);

        // Manufacturer.
        TextView versionManufacturerText = (TextView) tabLayout
                .findViewById(R.id.about_version_manufacturer_text);
        versionManufacturerText.setText(Build.MANUFACTURER);

        // Model.
        TextView versionModelText = (TextView) tabLayout.findViewById(R.id.about_version_model_text);
        versionModelText.setText(Build.MODEL);

        // Device.
        TextView versionDeviceText = (TextView) tabLayout.findViewById(R.id.about_version_device_text);
        versionDeviceText.setText(Build.DEVICE);

        // Bootloader.
        TextView versionBootloaderText = (TextView) tabLayout.findViewById(R.id.about_version_bootloader_text);
        versionBootloaderText.setText(Build.BOOTLOADER);

        // Radio.
        TextView versionRadioText = (TextView) tabLayout.findViewById(R.id.about_version_radio_text);
        // Hide versionRadioTextView if there is no radio.
        if (Build.getRadioVersion().equals("")) {
            TextView versionRadioTitle = (TextView) tabLayout.findViewById(R.id.about_version_radio_title);
            versionRadioTitle.setVisibility(View.GONE);
            versionRadioText.setVisibility(View.GONE);
        } else { // Else, set the text.
            versionRadioText.setText(Build.getRadioVersion());
        }

        // Android.
        TextView versionAndroidText = (TextView) tabLayout.findViewById(R.id.about_version_android_text);
        String android = Build.VERSION.RELEASE + " (" + getString(R.string.api) + " "
                + Integer.toString(Build.VERSION.SDK_INT) + ")";
        versionAndroidText.setText(android);

        // Build.
        TextView versionBuildText = (TextView) tabLayout.findViewById(R.id.about_version_build_text);
        versionBuildText.setText(Build.DISPLAY);

        // Security Patch.
        TextView versionSecurityPatchText = (TextView) tabLayout
                .findViewById(R.id.about_version_securitypatch_text);
        // Build.VERSION.SECURITY_PATCH is only available for SDK_INT >= 23.
        if (Build.VERSION.SDK_INT >= 23) {
            versionSecurityPatchText.setText(Build.VERSION.SECURITY_PATCH);
        } else { // Hide versionSecurityPatchTextView.
            TextView versionSecurityPatchTitle = (TextView) tabLayout
                    .findViewById(R.id.about_version_securitypatch_title);
            versionSecurityPatchTitle.setVisibility(View.GONE);
            versionSecurityPatchText.setVisibility(View.GONE);
        }

        // webViewLayout is only used to get the default user agent from about_tab_webview.  It is not used to render content on the screen.
        View webViewLayout = inflater.inflate(R.layout.about_tab_webview, container, false);
        WebView tabLayoutWebView = (WebView) webViewLayout.findViewById(R.id.about_tab_webview);
        String userAgentString = tabLayoutWebView.getSettings().getUserAgentString();

        // WebKit.
        TextView versionWebKitText = (TextView) tabLayout.findViewById(R.id.about_version_webkit_text);
        // Select the substring that begins after "Safari/" and goes to the end of the string.
        String webkitVersion = userAgentString.substring(userAgentString.indexOf("Safari/") + 7);
        versionWebKitText.setText(webkitVersion);

        // Chrome.
        TextView versionChromeText = (TextView) tabLayout.findViewById(R.id.about_version_chrome_text);
        // Select the substring that begins after "Chrome/" and goes until the next " ".
        String chromeVersion = userAgentString.substring(userAgentString.indexOf("Chrome/") + 7,
                userAgentString.indexOf(" ", userAgentString.indexOf("Chrome/")));
        versionChromeText.setText(chromeVersion);
    } else { // load a WebView for all the other tabs.  Tab numbers start at 0.
        // Setting false at the end of inflater.inflate does not attach the inflated layout as a child of container.
        // The fragment will take care of attaching the root automatically.
        tabLayout = inflater.inflate(R.layout.about_tab_webview, container, false);
        WebView tabWebView = (WebView) tabLayout;

        switch (tabNumber) {
        case 1:
            tabWebView.loadUrl("file:///android_asset/about_permissions.html");
            break;

        case 2:
            tabWebView.loadUrl("file:///android_asset/about_privacy_policy.html");
            break;

        case 3:
            tabWebView.loadUrl("file:///android_asset/about_changelog.html");
            break;

        case 4:
            tabWebView.loadUrl("file:///android_asset/about_license.html");
            break;

        case 5:
            tabWebView.loadUrl("file:///android_asset/about_contributors.html");
            break;

        case 6:
            tabWebView.loadUrl("file:///android_asset/about_links.html");

        default:
            break;
        }
    }

    return tabLayout;
}

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

/**
 * Returns a {@link String} representation to use as the User-Agent string when communicating
 * with the server. A sample string looks like:
 * <p/>/*w  w  w .  ja  v  a2  s.c  o  m*/
 * "LevelUp/2.3.12 (Linux; U; Android; 1.0; generic_x86/sd_x86; en-US;) LevelUpSdk/0.0.1".
 *
 * @param context Application context.
 * @return the user agent value.
 */
@NonNull
public static String getUserAgent(@NonNull final Context context) {
    return NullUtils.format("%s (Linux; U; Android %s; %s/%s; %s) %s", getUserAgentAppVersionString(context),
            Build.VERSION.RELEASE, Build.BRAND, Build.PRODUCT, Locale.getDefault().toString(),
            getUserAgentSdkVersionString(context));
}

From source file:com.android.test.gallery3d.common.HttpClientFactory.java

private static String getUserAgent(Context context) {
    if (sUserAgent == null) {
        PackageInfo pi;/*from  ww  w.  jav  a2 s. co m*/
        try {
            pi = context.getPackageManager().getPackageInfo(context.getPackageName(), 0);
        } catch (NameNotFoundException e) {
            throw new IllegalStateException("getPackageInfo failed");
        }
        sUserAgent = String.format("%s/%s; %s/%s/%s/%s; %s/%s/%s", pi.packageName, pi.versionName, Build.BRAND,
                Build.DEVICE, Build.MODEL, Build.ID, Build.VERSION.SDK, Build.VERSION.RELEASE,
                Build.VERSION.INCREMENTAL);
    }
    return sUserAgent;
}

From source file:com.android.fastergallery.common.HttpClientFactory.java

private static String getUserAgent(Context context) {
    if (sUserAgent == null) {
        PackageInfo pi;/*  w w w .ja  va2  s.  c  o m*/
        try {
            pi = context.getPackageManager().getPackageInfo(context.getPackageName(), 0);
        } catch (NameNotFoundException e) {
            throw new IllegalStateException("getPackageInfo failed");
        }
        sUserAgent = String.format("%s/%s; %s/%s/%s/%s; %s/%s/%s", pi.packageName, pi.versionName, Build.BRAND,
                Build.DEVICE, Build.MODEL, Build.ID, Build.VERSION.SDK_INT, Build.VERSION.RELEASE,
                Build.VERSION.INCREMENTAL);
    }
    return sUserAgent;
}

From source file:at.wada811.dayscounter.CrashExceptionHandler.java

/**
 * JSON??/*from   www  . ja v  a  2s . com*/
 *
 * @return
 *
 * @throws JSONException
 */
public static JSONObject getBuildInfo() {
    JSONObject json = new JSONObject();
    try {
        json.put("BRAND", Build.BRAND); // ?????(docomo)
        json.put("MODEL", Build.MODEL); // ????(SO-01C)
        json.put("DEVICE", Build.DEVICE); // ???(SO-01C)
        json.put("MANUFACTURER", Build.MANUFACTURER); // ??(Sony Ericsson)
        json.put("VERSION.SDK_INT", Build.VERSION.SDK_INT); // ??(10)
        json.put("VERSION.RELEASE", Build.VERSION.RELEASE); // ????(2.3.4)
    } catch (JSONException e) {
        e.printStackTrace();
    }
    return json;
}

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

/**
 * ??//  ww  w .  j a  v a2s  . co  m
 * @param cx 
 * @return BRAND ( MODEL )
 */
public static String getManu(Context cx) {

    return android.os.Build.BRAND + "(" + android.os.Build.MODEL + ")";
}

From source file:com.fallahpoor.infocenter.fragments.GeneralFragment.java

private ArrayList<String> getSubItemsArrayList() {

    return new ArrayList<>(Arrays.asList(new String[] { Build.MANUFACTURER, Build.BRAND, Build.DEVICE,
            Build.BOOTLOADER, Build.DISPLAY, Build.FINGERPRINT, getDeviceID(), Build.SERIAL,
            getRadioFirmwareVersion(), getFormattedUptime() }));

}

From source file:altermarkive.uploader.Report.java

private static JSONObject reportDevice(Context context) throws JSONException {
    JSONObject device = new JSONObject();
    device.put("id", hash(id(context)));
    device.put("manufacturer", Build.MANUFACTURER);
    device.put("brand", Build.BRAND);
    device.put("product", Build.PRODUCT);
    device.put("model", Build.MODEL);
    device.put("design", Build.DEVICE);
    device.put("board", Build.BOARD);
    device.put("hardware", Build.HARDWARE);
    device.put("build", Build.FINGERPRINT);
    return device;
}

From source file:com.apptentive.android.sdk.storage.DeviceManager.java

private static Device generateNewDevice(Context context) {
    Device device = new Device();

    // First, get all the information we can load from static resources.
    device.setOsName("Android");
    device.setOsVersion(Build.VERSION.RELEASE);
    device.setOsBuild(Build.VERSION.INCREMENTAL);
    device.setOsApiLevel(String.valueOf(Build.VERSION.SDK_INT));
    device.setManufacturer(Build.MANUFACTURER);
    device.setModel(Build.MODEL);//w w  w. j av a 2 s.  c  o m
    device.setBoard(Build.BOARD);
    device.setProduct(Build.PRODUCT);
    device.setBrand(Build.BRAND);
    device.setCpu(Build.CPU_ABI);
    device.setDevice(Build.DEVICE);
    device.setUuid(GlobalInfo.androidId);
    device.setBuildType(Build.TYPE);
    device.setBuildId(Build.ID);

    // Second, set the stuff that requires querying system services.
    TelephonyManager tm = ((TelephonyManager) (context.getSystemService(Context.TELEPHONY_SERVICE)));
    device.setCarrier(tm.getSimOperatorName());
    device.setCurrentCarrier(tm.getNetworkOperatorName());
    device.setNetworkType(Constants.networkTypeAsString(tm.getNetworkType()));

    // Finally, use reflection to try loading from APIs that are not available on all Android versions.
    device.setBootloaderVersion(Reflection.getBootloaderVersion());
    device.setRadioVersion(Reflection.getRadioVersion());

    device.setLocaleCountryCode(Locale.getDefault().getCountry());
    device.setLocaleLanguageCode(Locale.getDefault().getLanguage());
    device.setLocaleRaw(Locale.getDefault().toString());
    device.setUtcOffset(String.valueOf((TimeZone.getDefault().getRawOffset() / 1000)));
    return device;
}

From source file:de.akquinet.android.androlog.reporter.Report.java

/**
 * Adds the device data to the report./*  w  w  w. j  a va  2  s.  c om*/
 * @param context 
 * @throws JSONException if the device data cannot be added
 */
private void buildDeviceData(Context context) throws JSONException {
    device = new JSONObject();
    device.put("device", Build.DEVICE);
    device.put("brand", Build.BRAND);

    Object windowService = context.getSystemService(Context.WINDOW_SERVICE);
    if (windowService instanceof WindowManager) {
        Display display = ((WindowManager) windowService).getDefaultDisplay();
        device.put("resolution", display.getWidth() + "x" + display.getHeight());
        device.put("orientation", display.getOrientation());
    }
    device.put("display", Build.DISPLAY);
    device.put("manufacturer", Build.MANUFACTURER);
    device.put("model", Build.MODEL);
    device.put("product", Build.PRODUCT);
    device.put("build.type", Build.TYPE);
    device.put("android.version", Build.VERSION.SDK_INT);
}