Example usage for android.os Build DEVICE

List of usage examples for android.os Build DEVICE

Introduction

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

Prototype

String DEVICE

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

Click Source Link

Document

The name of the industrial design.

Usage

From source file:com.fabernovel.alertevoirie.webservice.HttpPostRequest.java

public String sendRequest() throws AVServiceErrorException {
    try {/*from  w  w  w.  j a v a 2  s  .co m*/

        httpPost = new HttpPost(url);

        HttpParams httpParameters = new BasicHttpParams();
        // Set the timeout in milliseconds until a connection is established.
        int timeoutConnection = 20000;
        HttpConnectionParams.setConnectionTimeout(httpParameters, timeoutConnection);
        // Set the default socket timeout (SO_TIMEOUT)
        // in milliseconds which is the timeout for waiting for data.
        int timeoutSocket = 5000;
        HttpConnectionParams.setSoTimeout(httpParameters, timeoutSocket);

        DefaultHttpClient httpClient = new DefaultHttpClient(httpParameters);

        httpPost.setEntity(new UrlEncodedFormEntity(params, HTTP.UTF_8));

        httpPost.addHeader(HEADER_APP_VERSION, "1.0.0");
        httpPost.addHeader(HEADER_APP_PLATFORM, "android_family");
        httpPost.addHeader(HEADER_APP_DEVICE_MODEL, (Build.MANUFACTURER + " " + Build.DEVICE).trim());
        httpPost.addHeader(HEADER_APP_REQUEST_SIGNATURE, sha1(MAGIC_KEY + params.get(0).getValue()));

        // Log.i(Constants.PROJECT_TAG,MAGIC_KEY + params.get(0).getValue());

        final HttpResponse response = httpClient.execute(httpPost);
        final HttpEntity entity = response.getEntity();
        content = entity.getContent();
        contentString = convertStreamToString(content);
        Log.d(Constants.PROJECT_TAG, "answer = " + contentString);
    } catch (final UnsupportedEncodingException uee) {
        Log.e(Constants.PROJECT_TAG, "UnsupportedEncodingException", uee);
        throw new AVServiceErrorException(999);
    } catch (final IOException ioe) {
        Log.e(Constants.PROJECT_TAG, "IOException", ioe);
        throw new AVServiceErrorException(999);
    } catch (final IllegalStateException ise) {
        Log.e(Constants.PROJECT_TAG, "IllegalStateException", ise);
        throw new AVServiceErrorException(999);
    } catch (NoSuchAlgorithmException e) {
        Log.e(Constants.PROJECT_TAG, "NoSuchAlgorithmException", e);
        throw new AVServiceErrorException(999);
    } catch (Exception e) {
        Log.e(Constants.PROJECT_TAG, "error in sendRequest : ", e);
        throw new AVServiceErrorException(999);
    }

    try {

        Log.d(Constants.PROJECT_TAG, "contenString: " + contentString);
        JSONObject jo = new JSONObject(contentString);
        int resultnum = jo.getJSONObject(JsonData.PARAM_ANSWER).getInt(JsonData.PARAM_STATUS);
        Log.i(Constants.PROJECT_TAG, "AV Status:" + resultnum);
        if (resultnum != 0)
            throw new AVServiceErrorException(resultnum);

    } catch (JSONException e) {
        Log.w(Constants.PROJECT_TAG, "JSONException in onPostExecute");
        //throw new AVServiceErrorException(999);
    }

    return contentString;
}

From source file:com.yojiokisoft.globish1500.exception.MyUncaughtExceptionHandler.java

/**
 * ?????.//from  w ww.ja va2  s .c  om
 */
private static void postBugReport() {
    List<NameValuePair> nvps = new ArrayList<NameValuePair>();
    String bug = getFileBody(sBugReportFile);
    nvps.add(new BasicNameValuePair("dev", Build.DEVICE));
    nvps.add(new BasicNameValuePair("mod", Build.MODEL));
    nvps.add(new BasicNameValuePair("sdk", Build.VERSION.SDK));
    nvps.add(new BasicNameValuePair("ver", sVersionName));
    nvps.add(new BasicNameValuePair("bug", bug));
    try {
        HttpPost httpPost = new HttpPost("http://mrp-bug-report.appspot.com/bug");
        httpPost.setEntity(new UrlEncodedFormEntity(nvps, HTTP.UTF_8));
        DefaultHttpClient httpClient = new DefaultHttpClient();
        httpClient.execute(httpPost);
    } catch (IOException e) {
        e.printStackTrace();
    }
    sBugReportFile.delete();
}

From source file:org.birthdayadapter.ui.BaseActivity.java

/**
 * Called when the activity is first created.
 *///www  .j a v a2s.  c  o  m
@Override
protected void onCreate(Bundle savedInstanceState) {
    super.onCreate(savedInstanceState);

    mActivity = this;

    requestWindowFeature(Window.FEATURE_INDETERMINATE_PROGRESS);

    if (Build.VERSION.SDK_INT < Build.VERSION_CODES.ICE_CREAM_SANDWICH) {
        // Load Activity for Android < 4.0
        Intent oldActivity = new Intent(mActivity, BaseActivityV8.class);
        oldActivity.setFlags(Intent.FLAG_ACTIVITY_NO_ANIMATION);
        startActivity(oldActivity);
        finish();
    } else {
        // Load new design with tabs
        mViewPager = new ViewPager(this);
        mViewPager.setId(R.id.pager);

        setContentView(mViewPager);

        ActionBar actionBar = getActionBar();
        actionBar.setNavigationMode(ActionBar.NAVIGATION_MODE_TABS);
        actionBar.setDisplayShowTitleEnabled(true);
        actionBar.setDisplayHomeAsUpEnabled(false);

        mTabsAdapter = new TabsAdapter(this, mViewPager);

        mTabsAdapter.addTab(actionBar.newTab().setText(getString(R.string.tab_main)), BaseFragment.class, null);

        mTabsAdapter.addTab(actionBar.newTab().setText(getString(R.string.tab_preferences)),
                PreferencesFragment.class, null);

        mTabsAdapter.addTab(actionBar.newTab().setText(getString(R.string.tab_accounts)),
                AccountListFragment.class, null);

        mTabsAdapter.addTab(actionBar.newTab().setText(getString(R.string.tab_help)), HelpFragment.class, null);

        mTabsAdapter.addTab(actionBar.newTab().setText(getString(R.string.tab_about)), AboutFragment.class,
                null);

        // default is disabled:
        mActivity.setProgressBarIndeterminateVisibility(Boolean.FALSE);

        mySharedPreferenceChangeListener = new MySharedPreferenceChangeListener(mActivity,
                mBackgroundStatusHandler);

        /*
         * Show workaround dialog for Android bug http://code.google.com/p/android/issues/detail?id=34880
         * Bug exists on Android 4.1 (SDK 16) and on some phones like Galaxy S4
         */
        if (BuildConfig.GOOGLE_PLAY_VERSION && PreferencesHelper.getShowWorkaroundDialog(mActivity)
                && !isPackageInstalled("org.birthdayadapter.jb.workaround")) {
            if ((Build.VERSION.SDK_INT == 16) || Build.DEVICE.toUpperCase().startsWith("GT-I9000")
                    || Build.DEVICE.toUpperCase().startsWith("GT-I9500")) {
                InstallWorkaroundDialogFragment dialog = InstallWorkaroundDialogFragment.newInstance();
                dialog.show(getFragmentManager(), "workaroundDialog");
            }
        }
    }
}

From source file:com.jaredrummler.android.device.DeviceName.java

/**
 * Get the consumer friendly name of the device.
 *
 * @return the market name of the current device.
 * @see #getDeviceName(String, String)/*from   w  w w. j  a  va 2 s.c om*/
 */
public static String getDeviceName() {
    String manufacturer = Build.MANUFACTURER;
    String model = Build.MODEL;
    String fallback;
    if (model.startsWith(manufacturer)) {
        fallback = capitalize(model);
    } else {
        fallback = capitalize(manufacturer) + " " + model;
    }
    return getDeviceName(Build.DEVICE, model, fallback);
}

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/*from ww w.  j  a  v  a 2  s  .  c om*/
 */
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:ota.otaupdates.MainActivity.java

@Override
protected void onCreate(Bundle savedInstanceState) {
    super.onCreate(savedInstanceState);

    sharedPreferences = PreferenceManager.getDefaultSharedPreferences(this);

    if (sharedPreferences.getBoolean("force_english", false)) {
        Locale myLocale = new Locale("en");
        Resources res = getResources();
        DisplayMetrics dm = res.getDisplayMetrics();
        Configuration conf = res.getConfiguration();
        conf.locale = myLocale;/*from  www .  j av  a  2  s . c o  m*/
        res.updateConfiguration(conf, dm);
    }

    if (sharedPreferences.getBoolean("apptheme_light", false))
        setTheme(R.style.AppTheme_Light);
    else
        setTheme(R.style.AppTheme_Dark);

    setContentView(R.layout.activity_main);

    build_url
            .append((Utils.doesPropExist(Constants.URL_PROP)) ? Utils.getProp(Constants.URL_PROP)
                    : getString(R.string.download_url))
            .append("/api/").append(Build.DEVICE).append("/").append(Build.TIME / 1000);

    build_dl_url.append((Utils.doesPropExist(Constants.URL_PROP)) ? Utils.getProp(Constants.URL_PROP)
            : getString(R.string.download_url)).append("/builds/");

    delta_url.append((Utils.doesPropExist(Constants.URL_PROP) ? Utils.getProp(Constants.URL_PROP)
            : getString(R.string.download_url))).append("/delta/").append(Build.VERSION.INCREMENTAL);

    delta_dl_url.append((Utils.doesPropExist(Constants.URL_PROP)) ? Utils.getProp(Constants.URL_PROP)
            : getString(R.string.download_url)).append("/deltas/");

    otaList = new ArrayList<>();
    get_builds();
    pb = (ProgressBar) findViewById(R.id.pb);
    pb.setVisibility(View.VISIBLE);

    final ListView ota_list = (ListView) findViewById(R.id.ota_list);

    adapter = new OTAUpdatesAdapter(getApplicationContext(), R.layout.row, otaList);
    ota_list.setAdapter(adapter);

    final CoordinatorLayout coordinator_root = (CoordinatorLayout) findViewById(R.id.coordinator_root);
    ota_list.setOnItemClickListener(new AdapterView.OnItemClickListener() {
        @Override
        public void onItemClick(AdapterView<?> arg0, View arg1, final int position, long id) {
            final String url = build_dl_url.toString() + otaList.get(position).getOta_filename();

            if (Build.VERSION.SDK_INT >= 23 && !checkPermission())
                allow_write_sd();
            else if (sharedPreferences.getBoolean("disable_mobile", true) && isMobileDataEnabled()) {
                sb_network = Snackbar.make(coordinator_root, getString(R.string.disable_mobile_message),
                        Snackbar.LENGTH_SHORT);
                sb_network.getView()
                        .setBackgroundColor(ContextCompat.getColor(MainActivity.this, R.color.colorSecond));
                sb_network.show();
            } else {
                new Thread(new Runnable() {
                    @Override
                    public void run() {
                        create_notification(1, getString(R.string.app_name), getString(
                                R.string.downloader_notification, otaList.get(position).getOta_filename()));
                        Utils.DownloadFromUrl(url, otaList.get(position).getOta_filename());
                        ((NotificationManager) getSystemService(Context.NOTIFICATION_SERVICE)).cancel(1);
                        runOnUiThread(new Runnable() {
                            @Override
                            public void run() {
                                if (MD5.checkMD5(otaList.get(position).getOta_md5(),
                                        new File(DL_PATH + otaList.get(position).getOta_filename()))
                                        || !sharedPreferences.getBoolean("md5_checking", true))
                                    trigger_autoinstall(DL_PATH + otaList.get(position).getOta_filename());
                                else {
                                    new AlertDialog.Builder(MainActivity.this)
                                            .setTitle(getString(R.string.md5_title))
                                            .setMessage(getString(R.string.md5_message)).setNeutralButton(
                                                    R.string.button_ok, new DialogInterface.OnClickListener() {
                                                        public void onClick(DialogInterface dialog, int which) {
                                                        }
                                                    })
                                            .show();
                                }
                            }
                        });
                    }
                }).start();
            }
        }
    });

}

From source file:com.imagine.BaseActivity.java

static String devName() {
    return android.os.Build.DEVICE;
}

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

/**
 * Get device information and save to application cache to send as attachment in feedback email.
 *///from  w ww  . j  a  v a2  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) {
    }
}

From source file:library.artaris.cn.library.utils.SystemUtils.java

/**
 * ??/*from   w  ww. j a  v  a2 s.  com*/
 * @return
 */
public static boolean isRunningOnEmulator() {
    return Build.BRAND.contains("generic") || Build.DEVICE.contains("generic") || Build.PRODUCT.contains("sdk")
            || Build.HARDWARE.contains("goldfish") || Build.MANUFACTURER.contains("Genymotion")
            || Build.PRODUCT.contains("vbox86p") || Build.DEVICE.contains("vbox86p")
            || Build.HARDWARE.contains("vbox86");
}

From source file:com.yojiokisoft.japanesecalc.MyUncaughtExceptionHandler.java

/**
 * ?????./*from  w  w  w .  j a  va2  s  .co  m*/
 */
private static void postBugReport() {
    List<NameValuePair> nvps = new ArrayList<NameValuePair>();
    String bug = getFileBody(sBugReportFile);
    nvps.add(new BasicNameValuePair("dev", Build.DEVICE));
    nvps.add(new BasicNameValuePair("mod", Build.MODEL));
    nvps.add(new BasicNameValuePair("sdk", String.valueOf(Build.VERSION.SDK_INT)));
    nvps.add(new BasicNameValuePair("ver", sVersionName));
    nvps.add(new BasicNameValuePair("bug", bug));
    try {
        HttpPost httpPost = new HttpPost("http://mrp-bug-report.appspot.com/bug");
        httpPost.setEntity(new UrlEncodedFormEntity(nvps, HTTP.UTF_8));
        DefaultHttpClient httpClient = new DefaultHttpClient();
        httpClient.execute(httpPost);
    } catch (IOException e) {
        e.printStackTrace();
    }
    sBugReportFile.delete();
}