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:com.lidroid.xutils.utils.OtherUtils.java

/**
 * @param context if null, use the default format
 *                (Mozilla/5.0 (Linux; U; Android %s) AppleWebKit/534.30 (KHTML, like Gecko) Version/4.0 %sSafari/534.30).
 * @return/*  w  ww  .j av a2  s. c o  m*/
 */
@SuppressLint("DefaultLocale")
public static String getUserAgent(Context context) {
    String webUserAgent = null;
    if (context != null) {
        try {
            Class<?> sysResCls = Class.forName("com.android.internal.R$string");
            Field webUserAgentField = sysResCls.getDeclaredField("web_user_agent");
            Integer resId = (Integer) webUserAgentField.get(null);
            webUserAgent = context.getString(resId);
        } catch (Throwable ignored) {
        }
    }
    if (TextUtils.isEmpty(webUserAgent)) {
        webUserAgent = "Mozilla/5.0 (Linux; U; Android %s) AppleWebKit/533.1 (KHTML, like Gecko) Version/4.0 %sSafari/533.1";
    }

    Locale locale = Locale.getDefault();
    StringBuffer buffer = new StringBuffer();
    // Add version
    final String version = Build.VERSION.RELEASE;
    if (version.length() > 0) {
        buffer.append(version);
    } else {
        // default to "1.0"
        buffer.append("1.0");
    }
    buffer.append("; ");
    final String language = locale.getLanguage();
    if (language != null) {
        buffer.append(language.toLowerCase());
        final String country = locale.getCountry();
        if (country != null) {
            buffer.append("-");
            buffer.append(country.toLowerCase());
        }
    } else {
        // default to "en"
        buffer.append("en");
    }
    // add the model for the release build
    if ("REL".equals(Build.VERSION.CODENAME)) {
        final String model = Build.MODEL;
        if (model.length() > 0) {
            buffer.append("; ");
            buffer.append(model);
        }
    }
    final String id = Build.ID;
    if (id.length() > 0) {
        buffer.append(" Build/");
        buffer.append(id);
    }
    return String.format(webUserAgent, buffer, "Mobile ");
}

From source file:com.teclib.flyvemdm.TabMyDevice.java

@Override
public void onViewCreated(View view, Bundle savedInstanceState) {

    String PhoneModel = android.os.Build.MODEL;
    String PhoneSerial = Build.SERIAL;
    sharedPreferenceMQTT = new SharedPreferenceMQTT();
    String MQTTServer = sharedPreferenceMQTT.getServer(mContext);

    // Set the Text to try this out
    TextView serial = (TextView) view.findViewById(R.id.serial);
    TextView model = (TextView) view.findViewById(R.id.model);
    TextView server = (TextView) view.findViewById(R.id.server);

    serial.setText("Serial : " + PhoneSerial);
    model.setText("Model :" + PhoneModel);
    server.setText("Server :" + MQTTServer);
}

From source file:com.cat.external.util.OtherUtils.java

/**
 * @param context if null, use the default format
 *                (Mozilla/5.0 (Linux; U; Android %s) AppleWebKit/534.30 (KHTML, like Gecko) Version/4.0 %sSafari/534.30).
 * @return//from   w  ww  .j a  v a2  s  .co m
 */
@SuppressLint("DefaultLocale")
public static String getUserAgent(Context context) {
    String webUserAgent = null;
    if (context != null) {
        try {
            @SuppressWarnings("rawtypes")
            Class sysResCls = Class.forName("com.android.internal.R$string");
            Field webUserAgentField = sysResCls.getDeclaredField("web_user_agent");
            Integer resId = (Integer) webUserAgentField.get(null);
            webUserAgent = context.getString(resId);
        } catch (Throwable ignored) {
        }
    }
    if (TextUtils.isEmpty(webUserAgent)) {
        webUserAgent = "Mozilla/5.0 (Linux; U; Android %s) AppleWebKit/533.1 (KHTML, like Gecko) Version/4.0 %sSafari/533.1";
    }

    Locale locale = Locale.getDefault();
    StringBuffer buffer = new StringBuffer();
    // Add version
    final String version = Build.VERSION.RELEASE;
    if (version.length() > 0) {
        buffer.append(version);
    } else {
        // default to "1.0"
        buffer.append("1.0");
    }
    buffer.append("; ");
    final String language = locale.getLanguage();
    if (language != null) {
        buffer.append(language.toLowerCase());
        final String country = locale.getCountry();
        if (country != null) {
            buffer.append("-");
            buffer.append(country.toLowerCase());
        }
    } else {
        // default to "en"
        buffer.append("en");
    }
    // add the model for the release build
    if ("REL".equals(Build.VERSION.CODENAME)) {
        final String model = Build.MODEL;
        if (model.length() > 0) {
            buffer.append("; ");
            buffer.append(model);
        }
    }
    final String id = Build.ID;
    if (id.length() > 0) {
        buffer.append(" Build/");
        buffer.append(id);
    }
    return String.format(webUserAgent, buffer, "Mobile ");
}

From source file:com.ruint.core.utils.OtherUtils.java

/**
 * @param context/*from  w w w  .  j  a  v a2 s  . c o m*/
 *          if null, use the default format (Mozilla/5.0 (Linux; U; Android
 *          %s) AppleWebKit/534.30 (KHTML, like Gecko) Version/4.0
 *          %sSafari/534.30).
 * @return
 */
@SuppressWarnings("rawtypes")
public static String getUserAgent(Context context) {
    String webUserAgent = null;
    if (context != null) {
        try {
            Class sysResCls = Class.forName("com.android.internal.R$string");
            Field webUserAgentField = sysResCls.getDeclaredField("web_user_agent");
            Integer resId = (Integer) webUserAgentField.get(null);
            webUserAgent = context.getString(resId);
        } catch (Throwable ignored) {
        }
    }
    if (TextUtils.isEmpty(webUserAgent)) {
        webUserAgent = "Mozilla/5.0 (Linux; U; Android %s) AppleWebKit/533.1 (KHTML, like Gecko) Version/4.0 %sSafari/533.1";
    }

    Locale locale = Locale.getDefault();
    StringBuffer buffer = new StringBuffer();
    // Add version
    final String version = Build.VERSION.RELEASE;
    if (version.length() > 0) {
        buffer.append(version);
    } else {
        // default to "1.0"
        buffer.append("1.0");
    }
    buffer.append("; ");
    final String language = locale.getLanguage();
    if (language != null) {
        buffer.append(language.toLowerCase());
        final String country = locale.getCountry();
        if (country != null) {
            buffer.append("-");
            buffer.append(country.toLowerCase());
        }
    } else {
        // default to "en"
        buffer.append("en");
    }
    // add the model for the release build
    if ("REL".equals(Build.VERSION.CODENAME)) {
        final String model = Build.MODEL;
        if (model.length() > 0) {
            buffer.append("; ");
            buffer.append(model);
        }
    }
    final String id = Build.ID;
    if (id.length() > 0) {
        buffer.append(" Build/");
        buffer.append(id);
    }
    return String.format(webUserAgent, buffer, "Mobile ");
}

From source file:com.anysoftkeyboard.ui.dev.DeveloperUtils.java

public static String getSysInfo(@Nullable Context context) {
    StringBuilder sb = new StringBuilder();
    sb.append("BRAND:").append(Build.BRAND).append(NEW_LINE);
    sb.append("DEVICE:").append(Build.DEVICE).append(NEW_LINE);
    sb.append("Build ID:").append(Build.DISPLAY).append(NEW_LINE);
    sb.append("changelist number:").append(Build.ID).append("\n");
    sb.append("MODEL:").append(Build.MODEL).append(NEW_LINE);
    sb.append("PRODUCT:").append(Build.PRODUCT).append(NEW_LINE);
    sb.append("TAGS:").append(Build.TAGS).append(NEW_LINE);
    sb.append("VERSION.INCREMENTAL:").append(Build.VERSION.INCREMENTAL).append(NEW_LINE);
    sb.append("VERSION.RELEASE:").append(Build.VERSION.RELEASE).append(NEW_LINE);
    sb.append("VERSION.SDK_INT:").append(Build.VERSION.SDK_INT).append(NEW_LINE);
    if (context != null && context.getResources() != null
            && context.getResources().getConfiguration() != null) {
        Configuration configuration = context.getResources().getConfiguration();
        sb.append("Locale:").append(configuration.locale).append(NEW_LINE);
        sb.append("configuration:").append(configuration.toString()).append(NEW_LINE);
    }//from  w  ww.j av  a2  s. co  m

    sb.append("That's all I know.");
    return sb.toString();
}

From source file:com.inter.trade.ui.fragment.buylicensekey.BuyLicenseKeySuccessFragment.java

private void initView(View view) {
    btn_ok = (Button) view.findViewById(R.id.btn_ok);
    tv_key = (TextView) view.findViewById(R.id.tv_key);

    btn_ok.setOnClickListener(this);

    if (!TextUtils.isEmpty(licenseKey)) {
        tv_key.setText("??" + licenseKey);
        BuyLicenseKeyMainFragment.licenseKey = licenseKey;

        String deviceModel = Build.MODEL;
        String deviceId = PhoneInfoUtil.getNativePhoneDeviceId(getActivity());
        if (!TextUtils.isEmpty(deviceModel) && !TextUtils.isEmpty(deviceId)) {
            BuyLicenseKeyMainFragment.deviceModel = deviceModel;
            BuyLicenseKeyMainFragment.deviceId = deviceId;
            BuyLicenseKeyMainFragment.isBindDevice = true;
            //            PromptUtil.showToast(getActivity(), "??\n"+"?"+deviceModel+"\nIMEI"+deviceId);
        }//from   ww  w.  j a  v a 2  s .  co  m
    }

}

From source file:com.fastbootmobile.encore.app.OmniMusic.java

@Override
public void onCreate() {
    super.onCreate();

    // We need to filter here whether we're initializing the main app or an aux attached plugin
    String appName = Utils.getAppNameByPID(this, android.os.Process.myPid());
    final String process = appName.substring(appName.indexOf(':') + 1);

    Sentry.setCaptureListener(new Sentry.SentryEventCaptureListener() {
        @Override/*from w ww.ja  va  2 s  . c o  m*/
        public Sentry.SentryEventBuilder beforeCapture(Sentry.SentryEventBuilder sentryEventBuilder) {
            JSONObject tags = sentryEventBuilder.getTags();
            try {
                tags.put("OS", "Android " + Build.VERSION.RELEASE);
                tags.put("OSCodename", Build.VERSION.CODENAME);
                tags.put("Device", Build.DEVICE);
                tags.put("Model", Build.MODEL);
                tags.put("Manufacturer", Build.MANUFACTURER);
                tags.put("AppVersionCode", String.valueOf(BuildConfig.VERSION_CODE));
                tags.put("AppVersionName", BuildConfig.VERSION_NAME);
                tags.put("AppFlavor", BuildConfig.FLAVOR);
            } catch (JSONException e) {
                Log.e(TAG, "Failed to put a tag into Sentry", e);
            }

            sentryEventBuilder.addModule(process, BuildConfig.VERSION_NAME);
            return sentryEventBuilder;
        }
    });
    Sentry.init(this,
            "https://4dc1acbdb1cb423282e2a59f553e1153:9415087b9e1348c3ba4bed44be599f6a@sentry.fastboot.mobi/2");

    // Setup LeakCanary
    mRefWatcher = LeakCanary.install(this);

    if (PROCESS_APP.equals(process)) {
        // Setup the plugins system
        ProviderAggregator.getDefault().setContext(getApplicationContext());
        PluginsLookup.getDefault().initialize(getApplicationContext());

        /**
         * Note about the cache and EchoNest: The HTTP cache would sometimes cache request
         * we didn't want (such as status query for Taste Profile update). We're using
         * a hacked jEN library that doesn't cache these requests.
         */
        // Setup network cache
        try {
            final File httpCacheDir = new File(getCacheDir(), "http");
            final long httpCacheSize = 100 * 1024 * 1024; // 100 MiB
            final HttpResponseCache cache = HttpResponseCache.install(httpCacheDir, httpCacheSize);

            Log.i(TAG, "HTTP Cache size: " + cache.size() / 1024 / 1024 + "MB");
        } catch (IOException e) {
            Log.w(TAG, "HTTP response cache installation failed", e);
        }

        // Setup image cache
        ImageCache.getDefault().initialize(getApplicationContext());

        // Setup Automix system
        AutoMixManager.getDefault().initialize(getApplicationContext());

        // Setup custom fonts
        CalligraphyConfig.initDefault("fonts/Roboto-Regular.ttf", R.attr.fontPath);
    }
}

From source file:tad.g730.mmfi.splash_activity.java

@Override
protected void onCreate(Bundle savedInstanceState) {
    super.onCreate(savedInstanceState);
    setTheme(R.style.CustomLightTheme);/*from  w  w w.  j a va 2 s. co  m*/
    sp = PreferenceManager.getDefaultSharedPreferences(getBaseContext());
    edit = sp.edit();
    setContentView(R.layout.splash_screen);
    splash_icon = (ImageView) findViewById(R.id.splash_icon);
    splash_text = (ImageView) findViewById(R.id.splash_text);
    splash_text.setVisibility(8);
    splash_icon.setVisibility(8);
    new Handler().postDelayed(new Runnable() {

        @Override
        public void run() {
            splash_icon.setVisibility(0);
            YoYo.with(Techniques.BounceInDown).duration(700).playOn(splash_icon);
        }
    }, 200);

    new Handler().postDelayed(new Runnable() {
        @Override
        public void run() {
            splash_text.setVisibility(0);
            boolean is_installed;
            is_installed = check_state.checkInstalled();

            /*save is_installed to default shared prefrences in
            in order to reduce main_acitivity loading time*/
            edit.putBoolean("is_installed", is_installed);
            edit.commit();
            YoYo.with(Techniques.Pulse).duration(700).playOn(splash_icon);

            YoYo.with(Techniques.BounceInUp).duration(700).playOn(splash_text);

        }
    }, 700);
    if (!Build.MODEL.contains("G730-U00") || Build.VERSION.SDK_INT != 17) {
        new Handler().postDelayed(new Runnable() {

            @Override
            public void run() {
                SimpleDialogFragment.createBuilder(getBaseContext(), getSupportFragmentManager())
                        .setMessage(R.string.device_not_compatible).setTitle(R.string.app_name)
                        .setCancelable(false).setCancelableOnTouchOutside(false).show();
            }
        }, 1600);

        //AlertDialog.Builder builder=new AlertDialog.Builder(this);
        //builder.setTitle(R.string.app_name).setMessage(R.string.device_not_compatible).show();
    } else {

        new Handler().postDelayed(new Runnable() {

            // Using handler with postDelayed called runnable run method

            @Override
            public void run() {
                Intent i = new Intent();
                //the value of is_agreed is assigned in terms and condition activity
                if (sp.getBoolean("is_agreed", false)) {
                    i = new Intent(getBaseContext(), main_activity.class);
                } else {
                    i = new Intent(getBaseContext(), terms_condition.class);
                }
                startActivity(i);
                overridePendingTransition(R.anim.flip_vertical_in, R.anim.flip_vertical_out);
                //appearBottomRightAnimation

                // close this activity
                finish();
            }
        }, 1600); // wait for 5 seconds
    }
}

From source file:com.activiti.android.platform.intent.IntentUtils.java

public static boolean actionSendFeedbackEmail(Fragment fr) {
    try {//from   w w w  .j  a  v a  2 s  .co  m
        ShareCompat.IntentBuilder iBuilder = ShareCompat.IntentBuilder.from(fr.getActivity());
        Context context = fr.getContext();
        // Email
        iBuilder.addEmailTo(context.getResources().getStringArray(R.array.bugreport_email));

        // Prepare Subject
        String versionName = context.getPackageManager().getPackageInfo(context.getPackageName(),
                0).versionName;
        int versionCode = context.getPackageManager().getPackageInfo(context.getPackageName(), 0).versionCode;

        String subject = "Alfresco Activiti Android Feedback";
        iBuilder.setSubject(subject);

        // Content
        DisplayMetrics dm = context.getResources().getDisplayMetrics();
        String densityBucket = getDensityString(dm);

        Map<String, String> info = new LinkedHashMap<>();
        info.put("Version", versionName);
        info.put("Version code", Integer.toString(versionCode));
        info.put("Make", Build.MANUFACTURER);
        info.put("Model", Build.MODEL);
        info.put("Resolution", dm.heightPixels + "x" + dm.widthPixels);
        info.put("Density", dm.densityDpi + "dpi (" + densityBucket + ")");
        info.put("Release", Build.VERSION.RELEASE);
        info.put("API", String.valueOf(Build.VERSION.SDK_INT));
        info.put("Language", context.getResources().getConfiguration().locale.getDisplayLanguage());

        StringBuilder builder = new StringBuilder();
        builder.append("\n\n\n\n");
        builder.append("Alfresco Activiti Mobile and device details\n");
        builder.append("-------------------\n").toString();
        for (Map.Entry entry : info.entrySet()) {
            builder.append(entry.getKey()).append(": ").append(entry.getValue()).append('\n');
        }

        builder.append("-------------------\n\n").toString();
        iBuilder.setType("message/rfc822");
        iBuilder.setText(builder.toString());
        iBuilder.setChooserTitle(fr.getString(R.string.settings_feedback_email)).startChooser();

        return true;
    } catch (Exception e) {
        Log.d("Action Send Feedback", Log.getStackTraceString(e));
    }

    return false;
}

From source file:com.auth0.api.internal.BaseRequest.java

public BaseRequest(Handler handler, HttpUrl url, OkHttpClient client, ObjectReader reader, ObjectWriter writer,
        BaseCallback<T> callback) {
    this.handler = handler;
    this.url = url;
    this.client = client;
    this.reader = reader;
    this.writer = writer;
    this.callback = callback;
    this.headers = new HashMap<>();
    this.parameters = new HashMap<>();
    this.headers.put("User-Agent",
            String.format("Android %s (%s %s;)", Build.VERSION.RELEASE, Build.MODEL, Build.MANUFACTURER));
}