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:org.peercast.pecaport.AddMappingDialog.java

public AddMappingDialog(Context c, int pecaRunningPort, Collection<WanConnection> connected,
        final Inet4Address clientIp, final Listener listener) {

    String port, description;/*from   www.  j a v  a  2 s .co m*/
    if (pecaRunningPort > 0) {
        port = pecaRunningPort + "";
        description = PecaPortService.DESCRIPTION;
    } else {
        port = "";
        String modelName = StringUtils.substring(Build.MODEL, 0, 16);
        description = String.format("PecaPort(%s)", modelName);
    }

    View view = LayoutInflater.from(c).inflate(R.layout.add_port_dialog, null);
    vPrivateIp = (TextView) view.findViewById(R.id.vPrivateIp);
    vPrivateIp.setText(clientIp.getHostAddress());

    vConnections = (Spinner) view.findViewById(R.id.vConnections);

    vExternalPort = (EditText) view.findViewById(R.id.vExternalPort);
    vExternalPort.addTextChangedListener(mValidPortWatcher);
    vExternalPort.setText(port);

    vInternalPort = (EditText) view.findViewById(R.id.vInternalPort);
    vInternalPort.setText(vExternalPort.getText());
    vInternalPort.addTextChangedListener(mValidPortWatcher);

    vSomePort = (CheckBox) view.findViewById(R.id.vSamePort);
    vSomePort.setOnCheckedChangeListener(new CompoundButton.OnCheckedChangeListener() {
        @Override
        public void onCheckedChanged(CompoundButton buttonView, boolean isChecked) {
            if (isChecked) {
                vInternalPort.setText(vExternalPort.getText());
                vInternalPort.setEnabled(false);
            } else {
                vInternalPort.setEnabled(true);
            }
        }
    });
    vExternalPort.addTextChangedListener(new TextWatcher() {
        @Override
        public void beforeTextChanged(CharSequence s, int start, int count, int after) {
        }

        @Override
        public void onTextChanged(CharSequence s, int start, int before, int count) {
        }

        @Override
        public void afterTextChanged(Editable s) {
            if (vSomePort.isChecked()) {
                vInternalPort.setText(vExternalPort.getText());
            }
        }
    });

    vTcp = (RadioButton) view.findViewById(R.id.vTcp);
    vDescription = (EditText) view.findViewById(R.id.vDescription);

    vDescription.setText(description);

    WanConnectionsAdapter wanAdapter = new WanConnectionsAdapter();

    wanAdapter.setConnections(connected);
    vConnections.setAdapter(wanAdapter);

    mBuilder = new AlertDialog.Builder(c).setTitle(R.string.t_add_port).setView(view)
            .setPositiveButton(android.R.string.ok, new DialogInterface.OnClickListener() {
                @Override
                public void onClick(DialogInterface dialog, int which) {
                    PortMapping mapping = new PortMapping();
                    mapping.setExternalPort(toUI2Bytes(vExternalPort));
                    mapping.setInternalPort(toUI2Bytes(vInternalPort));
                    mapping.setDescription(vDescription.getText().toString());
                    mapping.setInternalClient(vPrivateIp.getText().toString());
                    mapping.setEnabled(true);
                    mapping.setProtocol(vTcp.isChecked() ? PortMapping.Protocol.TCP : PortMapping.Protocol.UDP);
                    listener.onOkClick((WanConnection) vConnections.getSelectedItem(), mapping);
                }
            }).setIcon(R.drawable.ic_plus_box).setNegativeButton(android.R.string.cancel, null)
            .setCancelable(false);
}

From source file:com.doomonafireball.hackerswiperfree.android.activity.MainActivity.java

@Override
public void onCreate(Bundle savedInstanceState) {
    requestWindowFeature(Window.FEATURE_ACTION_BAR_OVERLAY);
    super.onCreate(savedInstanceState);
    setContentView(R.layout.activity_main);

    text.append("@" + Build.MODEL.replaceAll("\\s+", "").toLowerCase().trim() + ": ");

    mTyper = new Typer(this);
    mTouchSlop = ViewConfiguration.get(this).getScaledTouchSlop();

    scrollView.setOnTouchListener(this);

    // TODO Set window padding
    int leftRightPadding = getResources().getDimensionPixelSize(R.dimen.default_padding);
    SystemBarTintManager.SystemBarConfig config = new SystemBarTintManager(this).getConfig();
    text.setPadding(leftRightPadding, config.getPixelInsetTop(false) + leftRightPadding,
            config.getPixelInsetRight() + leftRightPadding, config.getPixelInsetBottom() + leftRightPadding);
}

From source file:at.wada811.android.library.demos.CrashExceptionHandler.java

/**
 * JSON??/*from  w w w .j a v a2 s  .  c  om*/
 * 
 * @return
 * @throws JSONException
 */
private 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:org.pixmob.feedme.net.NetworkClient.java

/**
 * Generate an Http User-Agent./*from   w  w w .ja v  a  2s. c o m*/
 */
private static final String generateUserAgent(Context context) {
    String applicationVersion = null;
    try {
        applicationVersion = context.getPackageManager().getPackageInfo(context.getPackageName(),
                0).versionName;
    } catch (NameNotFoundException e) {
        applicationVersion = "0.0.0";
    }
    return context.getApplicationInfo().name + "/" + applicationVersion + " (" + Build.MANUFACTURER + " "
            + Build.MODEL + " with Android " + Build.VERSION.RELEASE + "/" + Build.VERSION.SDK_INT + ")";
}

From source file:ua.naiksoftware.chars.Sender.java

/**
 *
 * @param <b>p</b> score and time
 * @return true if ok, else false/*from   ww w  . j  a va2  s .c o  m*/
 */
@Override
protected Boolean doInBackground(Integer... p) {
    Log.d(tag, "doInBacckground begin");
    int score = p[0];
    int time = p[1];
    String model = Build.MANUFACTURER + " " + Build.MODEL;
    String devId = Build.FINGERPRINT;
    if (model == null || model.equals("")) {
        model = "Unknown";
    }
    Log.d(tag, "doInBackground: data set: devId=" + (devId == null ? "null" : devId));
    HttpClient httpclient = new DefaultHttpClient();
    HttpPost httppost = new HttpPost(URL.replace("game", "chars"));
    Log.d(tag, "doInBackground: httppost created");

    HttpResponse response = null;
    try {
        // Add my data
        List<NameValuePair> nameValuePairs = new ArrayList<NameValuePair>(7);
        nameValuePairs.add(new BasicNameValuePair("score", String.valueOf(score)));
        nameValuePairs.add(new BasicNameValuePair("time", String.valueOf(time)));
        nameValuePairs.add(new BasicNameValuePair("l", MainActivity.login));
        nameValuePairs.add(new BasicNameValuePair("p", MainActivity.pass));
        nameValuePairs.add(new BasicNameValuePair("model", model));
        nameValuePairs.add(new BasicNameValuePair("devid", devId));
        nameValuePairs.add(new BasicNameValuePair("valid",
                md5(MainActivity.login + MainActivity.pass + MainActivity.login.length())));
        httppost.setEntity(new UrlEncodedFormEntity(nameValuePairs));

        Log.d(tag, "doInBackground: form set, pre execute httpclient");
        // Execute HTTP Post Request
        response = httpclient.execute(httppost);
        Log.d(tag, "doInBackground: executed httpclient");

    } catch (ClientProtocolException e) {
        Log.e(tag, "doInBackground: protocol exception", e);
        err = e.getMessage().replace("eof-cms.h2m.ru", "annimon.com");// security :)
        return false;
    } catch (IOException e) {
        Log.d(tag, "doInBackground: IOException", e);
        err = e.getMessage().replace("eof-cms.h2m.ru", "annimon.com");// security :)
        return false;
    }
    Log.d(tag, "doInBackground: all right (end)");
    return true;
}

From source file:org.wahtod.wififixer.utility.LogUtil.java

public static String getBuildInfo() {
    StringBuilder out = new StringBuilder("");
    out.append(Build.MODEL);
    out.append(NEWLINE);/*from   w w w  .j  a va2 s  . c  om*/
    out.append(Build.VERSION.RELEASE);
    out.append(NEWLINE);
    return out.toString();
}

From source file:com.auth0.api.BaseAPIClient.java

public BaseAPIClient(String clientID, String baseURL, String configurationURL, String tenantName) {
    this.clientID = clientID;
    this.configurationURL = configurationURL;
    this.baseURL = baseURL;
    this.client = new AsyncHttpClient();
    if (tenantName == null) {
        Uri uri = Uri.parse(baseURL);//from w  w w  .  j a  va 2  s  .  c o m
        this.tenantName = uri.getHost();
    } else {
        this.tenantName = tenantName;
    }
    this.client
            .setUserAgent(String.format("%s (%s Android %s)", tenantName, Build.MODEL, Build.VERSION.RELEASE));
    this.entityBuilder = new JsonEntityBuilder(new ObjectMapper());
}

From source file:com.libframework.annotation.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  w  w.  ja v a2  s.com
 */
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(Locale.getDefault()));
        final String country = locale.getCountry();
        if (country != null) {
            buffer.append("-");
            buffer.append(country.toLowerCase(Locale.getDefault()));
        }
    } 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.ddiiyy.xydz.xutils.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//  w  w w .  j  a v  a  2 s.c  o  m
 */
@SuppressLint("DefaultLocale")
@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.linroid.pushapp.ui.bind.BindActivity.java

@Override
protected void onCreate(Bundle savedInstanceState) {
    super.onCreate(savedInstanceState);
    handleIntent(getIntent());// ww  w  .j  a va2 s  .c  o m
    aliasET.setText(getString(R.string.tpl_alias_default, Build.MODEL, Build.VERSION.RELEASE));
    firstContentTV.setText(getString(R.string.bind_fist_content, BuildConfig.HOST_URL));
    App.from(this).component().inject(this);

}