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.liato.bankdroid.Helpers.java

public static String getAppUserAgentString(Context context) {
    if (USER_AGENT != null)
        return USER_AGENT;
    String appName = context.getResources().getString(R.string.app_name);
    String appVersion = "";
    int height = 0;
    int width = 0;
    DisplayMetrics display = context.getResources().getDisplayMetrics();
    Configuration config = context.getResources().getConfiguration();

    // Always send screen dimension for portrait mode
    if (config.orientation == Configuration.ORIENTATION_LANDSCAPE) {
        height = display.widthPixels;//from w w  w.  jav a2 s.  c o m
        width = display.heightPixels;
    } else {
        width = display.widthPixels;
        height = display.heightPixels;
    }

    try {
        PackageInfo packageInfo = context.getPackageManager().getPackageInfo(context.getPackageName(),
                PackageManager.GET_CONFIGURATIONS);
        appVersion = packageInfo.versionName;
    } catch (PackageManager.NameNotFoundException ignore) {
        // this should never happen, we are looking up ourself
    }

    // Tries to conform to default android UA string without the Safari / webkit noise, plus adds the screen dimensions
    USER_AGENT = String.format(
            "%1$s/%2$s (%3$s; U; Android %4$s; %5$s-%6$s; %12$s Build/%7$s; %8$s) %9$dX%10$d %11$s %12$s",
            appName, appVersion, System.getProperty("os.name", "Linux"), Build.VERSION.RELEASE,
            config.locale.getLanguage().toLowerCase(), config.locale.getCountry().toLowerCase(), Build.ID,
            Build.BRAND, width, height, Build.MANUFACTURER, Build.MODEL);
    return USER_AGENT;
}

From source file:com.aujur.ebookreader.Configuration.java

public String getUserAgent() {
    return context.getString(R.string.app_name) + "-" + getAppVersion() + "/" + Build.MODEL + ";Android-"
            + Build.VERSION.RELEASE;/*  w ww.  jav  a2  s .c  o m*/
}

From source file:com.qihoo.permmgr.PermManager.java

public int doSolutionOnline(MainActivity activity) {
    String str1 = SystemProperties.get("ro.build.version.release");
    if (TextUtils.isEmpty(str1))
        str1 = "unknow";
    String str2 = Build.MODEL;
    if (TextUtils.isEmpty(str2))
        str2 = "unknow";
    String str3 = "unknow";
    if ((!TextUtils.isEmpty(SystemProperties.get("ro.product.manufacturer")))
            || (!TextUtils.isEmpty(SystemProperties.get("ro.mtk.hardware"))))
        str3 = "mtk";
    String str4 = com.qihoo.permmgr.util.k.a(mContext);
    String str5 = com.qihoo.permmgr.util.f.a(str4);
    if (TextUtils.isEmpty(str4))
        str5 = "unknow";
    File localFile = new File("/");
    String[] arrayOfString = new String[2];
    arrayOfString[0] = "cat";
    arrayOfString[1] = "/proc/version";
    String str6 = com.qihoo.permmgr.util.b.a(localFile, arrayOfString);
    String str7 = str6.split(" ")[2];
    String str8 = "model=" + URLEncoder.encode(str2) + "&target=1&buildno=" + URLEncoder.encode(str7)
            + "&version=" + URLEncoder.encode(str1) + "&platform=" + URLEncoder.encode(str3);
    String url = "http://api.shuaji.360.cn/c/getSolution?" + str8 + "&pkg=" + a.e + "&mid="
            + URLEncoder.encode(str5) + "&new=" + 1 + "&src=1";
    Log.d(TAG, "url:" + url);
    try {//  w  w  w  .j  a v a 2s.c o  m
        HttpGet localHttpGet2 = new HttpGet(url);
        HttpResponse localHttpResponse = new DefaultHttpClient().execute(localHttpGet2);
        int statusCode = localHttpResponse.getStatusLine().getStatusCode();
        String jsonData = AESUtils.b(EntityUtils.toString(localHttpResponse.getEntity()));
        JSONArray arr = new JSONArray(jsonData);
        byte[] bs = new byte[1024];
        int len;
        for (int i = 0; i < arr.length(); i++) {
            JSONObject temp = (JSONObject) arr.get(i);
            String md5 = temp.getString("solution_md5");
            String solution = temp.getString("solution");
            activity.setStatus("downloading " + solution + "\n");
            URL sUrl = new URL(solution);
            URLConnection con = sUrl.openConnection();
            InputStream is = con.getInputStream();
            String md5FilePath = mContext.getFilesDir().getAbsoluteFile() + "/permmgr/" + md5;
            OutputStream os = new FileOutputStream(md5FilePath);
            while ((len = is.read(bs)) != -1) {
                os.write(bs, 0, len);
            }
            os.close();
            is.close();
            activity.setStatus("executing " + md5 + "\n\n");
            if (RootMan.getInstance(mContext).doRoot(md5FilePath) == Constants.ROOT_SUCCESS) {
                SharedStore store = new SharedStore(mContext, Constants.SOLUTION_FILE);
                store.putString(Constants.KEY_SOLUTION_MD5, md5);
                return Constants.ROOT_SUCCESS;
            }
        }

    } catch (Exception e) {
        e.printStackTrace();
    }
    return Constants.NOTSUPPORT;
}

From source file:de.schildbach.wallet.ui.ReportIssueDialogFragment.java

private 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(Build.VERSION.SDK_INT >= Build.VERSION_CODES.LOLLIPOP ? supportedAbisLollipop()
                            : supportedAbisKitKat()))
            .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(//from  w  w w.  ja  va2  s .  c o  m
            "Memory Class: " + activityManager.getMemoryClass() + "/" + activityManager.getLargeMemoryClass()
                    + (activityManager.isLowRamDevice() ? " (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:com.example.adarshgupta.wallpapertemplate.HomeActivity.java

@Override
public boolean onOptionsItemSelected(MenuItem item) {
    super.onOptionsItemSelected(item);

    switch (item.getItemId()) {
    case R.id.share:
        Intent sharingIntent = new Intent(Intent.ACTION_SEND);
        sharingIntent.setType("text/plain");
        String shareBody = getResources().getString(R.string.share_one)
                + getResources().getString(R.string.iconpack_designer)
                + getResources().getString(R.string.share_two) + MARKET_URL + getPackageName();
        sharingIntent.putExtra(Intent.EXTRA_TEXT, shareBody);
        startActivity(Intent.createChooser(sharingIntent, (getResources().getString(R.string.share_title))));
        break;/*from w ww .  jav  a 2s  . c om*/

    case R.id.sendemail:
        StringBuilder emailBuilder = new StringBuilder();

        Intent intent = new Intent(Intent.ACTION_VIEW,
                Uri.parse("mailto:" + getResources().getString(R.string.email_id)));
        intent.putExtra(Intent.EXTRA_SUBJECT, getResources().getString(R.string.email_subject));

        emailBuilder.append("\n \n \nOS Version: ").append(System.getProperty("os.version")).append("(")
                .append(Build.VERSION.INCREMENTAL).append(")");
        emailBuilder.append("\nOS API Level: ").append(Build.VERSION.SDK_INT);
        emailBuilder.append("\nDevice: ").append(Build.DEVICE);
        emailBuilder.append("\nManufacturer: ").append(Build.MANUFACTURER);
        emailBuilder.append("\nModel (and Product): ").append(Build.MODEL).append(" (").append(Build.PRODUCT)
                .append(")");
        PackageInfo appInfo = null;
        try {
            appInfo = getPackageManager().getPackageInfo(getPackageName(), 0);
        } catch (PackageManager.NameNotFoundException e) {
            e.printStackTrace();
        }
        assert appInfo != null;
        emailBuilder.append("\nApp Version Name: ").append(appInfo.versionName);
        emailBuilder.append("\nApp Version Code: ").append(appInfo.versionCode);

        intent.putExtra(Intent.EXTRA_TEXT, emailBuilder.toString());
        startActivity(Intent.createChooser(intent, (getResources().getString(R.string.send_title))));
        break;

    case R.id.changelog:
        showChangelog();
        break;
    }
    return true;
}

From source file:git.egatuts.nxtremotecontroller.fragment.OnlineControllerFragment.java

public TokenRequester getTokenRequester() {
    final OnlineControllerFragment self = this;
    final TokenRequester requester = new TokenRequester();
    requester.setRunnable(new Runnable() {
        @Override/*  w ww. j  a  va2 s  .c  o m*/
        public void run() {
            String url = self.getPreferencesEditor().getString("preference_server_login",
                    self.getString(R.string.preference_value_login));
            try {
                URL location = new URL(url);
                HttpsURLConnection s_connection = null;
                HttpURLConnection connection = null;
                InputStream input;
                int responseCode;
                boolean isHttps = url.contains("https");
                DataOutputStream writeStream;
                if (isHttps) {
                    s_connection = (HttpsURLConnection) location.openConnection();
                    s_connection.setRequestMethod("POST");
                    writeStream = new DataOutputStream(s_connection.getOutputStream());
                } else {
                    connection = (HttpURLConnection) location.openConnection();
                    connection.setRequestMethod("POST");
                    writeStream = new DataOutputStream(connection.getOutputStream());
                }
                StringBuilder urlParams = new StringBuilder();
                urlParams.append("name=").append(Build.MODEL).append("&email=").append(self.getOwnerEmail())
                        .append("&host=").append(true).append("&longitude=").append(self.longitude)
                        .append("&latitude=").append(self.latitude);
                writeStream.writeBytes(urlParams.toString());
                writeStream.flush();
                writeStream.close();
                if (isHttps) {
                    input = s_connection.getInputStream();
                    responseCode = s_connection.getResponseCode();
                } else {
                    input = connection.getInputStream();
                    responseCode = connection.getResponseCode();
                }
                if (input != null) {
                    BufferedReader bufferedReader = new BufferedReader(new InputStreamReader(input));
                    String line;
                    String result = "";
                    while ((line = bufferedReader.readLine()) != null) {
                        result += line;
                    }
                    input.close();
                    requester.finishRequest(result);
                }
            } catch (IOException e) {
                //e.printStackTrace();
                requester.cancelRequest(e);
            }
        }
    });
    return requester;
}

From source file:com.knightlabs.orion_base.activities.Main.java

@Override
public boolean onOptionsItemSelected(MenuItem item) {
    super.onOptionsItemSelected(item);

    switch (item.getItemId()) {
    case R.id.share:
        Intent sharingIntent = new Intent(Intent.ACTION_SEND);
        sharingIntent.setType("text/plain");
        String shareBody = "Check out this awesome icon pack by "
                + getResources().getString(R.string.orion_author) + ". Download Here: "
                + getResources().getString(R.string.website_link);
        sharingIntent.putExtra(Intent.EXTRA_TEXT, shareBody);
        startActivity(Intent.createChooser(sharingIntent, (getResources().getString(R.string.share_title))));
        break;//from   w  w  w .  j a v  a2 s .  c  om

    case R.id.sendemail:
        StringBuilder emailBuilder = new StringBuilder();

        Intent intent = new Intent(Intent.ACTION_VIEW,
                Uri.parse("mailto:" + getResources().getString(R.string.email_id)));
        intent.putExtra(Intent.EXTRA_SUBJECT, getResources().getString(R.string.email_subject));

        emailBuilder.append("\n \n \nOS Version: " + System.getProperty("os.version") + "("
                + Build.VERSION.INCREMENTAL + ")");
        emailBuilder.append("\nOS API Level: " + Build.VERSION.SDK_INT);
        emailBuilder.append("\nDevice: " + Build.DEVICE);
        emailBuilder.append("\nManufacturer: " + Build.MANUFACTURER);
        emailBuilder.append("\nModel (and Product): " + Build.MODEL + " (" + Build.PRODUCT + ")");
        PackageInfo appInfo = null;
        try {
            appInfo = getPackageManager().getPackageInfo(getPackageName(), 0);
        } catch (PackageManager.NameNotFoundException e) {
            e.printStackTrace();
        }
        emailBuilder.append("\nApp Version Name: " + appInfo.versionName);
        emailBuilder.append("\nApp Version Code: " + appInfo.versionCode);

        intent.putExtra(Intent.EXTRA_TEXT, emailBuilder.toString());
        startActivity(Intent.createChooser(intent, (getResources().getString(R.string.send_title))));
        break;

    case R.id.changelog:
        changelog();
        break;
    }
    return true;
}

From source file:edu.gatech.ppl.cycleatlanta.TripUploader.java

public String getAppVersion() {
    String versionName = "";
    int versionCode = 0;

    try {/*from  www .  j a v a 2  s  . c  o  m*/
        PackageInfo pInfo = mCtx.getPackageManager().getPackageInfo(mCtx.getPackageName(), 0);
        versionName = pInfo.versionName;
        versionCode = pInfo.versionCode;
    } catch (PackageManager.NameNotFoundException e) {
        e.printStackTrace();
    }

    String systemVersion = Build.VERSION.RELEASE;

    String manufacturer = Build.MANUFACTURER;
    String model = Build.MODEL;
    if (model.startsWith(manufacturer)) {
        return versionName + " (" + versionCode + ") on Android " + systemVersion + " " + capitalize(model);
    } else {
        return versionName + " (" + versionCode + ") on Android " + systemVersion + " "
                + capitalize(manufacturer) + " " + model;
    }
}

From source file:com.pimp.companionforband.activities.main.MainActivity.java

@Override
public void onNegativeReview(int stars) {
    StringBuilder emailBuilder = new StringBuilder();
    Intent intent = new Intent(Intent.ACTION_VIEW, Uri.parse("mailto:pimplay69@gmail.com"));
    intent.putExtra(Intent.EXTRA_SUBJECT,
            getString(R.string.feedback) + " : " + getResources().getString(R.string.app_name));

    emailBuilder.append("\n \n \nOS Version: ").append(System.getProperty("os.version")).append("(")
            .append(Build.VERSION.INCREMENTAL).append(")");
    emailBuilder.append("\nOS API Level: ").append(Build.VERSION.SDK_INT);
    emailBuilder.append("\nDevice: ").append(Build.DEVICE);
    emailBuilder.append("\nManufacturer: ").append(Build.MANUFACTURER);
    emailBuilder.append("\nModel (and Product): ").append(Build.MODEL).append(" (").append(Build.PRODUCT)
            .append(")");
    PackageInfo appInfo = null;//  ww w.j a v a 2s.  c  o m
    try {
        appInfo = getPackageManager().getPackageInfo(getPackageName(), 0);
    } catch (PackageManager.NameNotFoundException e) {
        e.printStackTrace();
    }
    assert appInfo != null;
    emailBuilder.append("\nApp Version Name: ").append(appInfo.versionName);
    emailBuilder.append("\nApp Version Code: ").append(appInfo.versionCode);

    intent.putExtra(Intent.EXTRA_TEXT, emailBuilder.toString());
    startActivity(Intent.createChooser(intent, "Send via"));
}

From source file:org.opendatakit.survey.android.activities.MediaCaptureVideoActivity.java

@Override
public void onActivityResult(int requestCode, int resultCode, Intent intent) {

    if (resultCode == Activity.RESULT_CANCELED) {
        // request was canceled -- propagate
        setResult(Activity.RESULT_CANCELED);
        finish();/*from w ww.j a v  a  2  s  .  c o  m*/
        return;
    }

    Uri mediaUri = intent.getData();

    // it is unclear whether getData() always returns a value or if
    // getDataString() does...
    String str = intent.getDataString();
    if (mediaUri == null && str != null) {
        WebLogger.getLogger(appName).w(t, "Attempting to work around null mediaUri");
        mediaUri = Uri.parse(str);
    }

    if (mediaUri == null) {
        // we are in trouble
        WebLogger.getLogger(appName).e(t, "No uri returned from ACTION_CAPTURE_VIDEO!");
        setResult(Activity.RESULT_CANCELED);
        finish();
        return;
    }

    // Remove the current media.
    deleteMedia();

    // get the file path and create a copy in the instance folder
    String binaryPath = MediaUtils.getPathFromUri(this, (Uri) mediaUri, Video.Media.DATA);
    File source = new File(binaryPath);
    String extension = binaryPath.substring(binaryPath.lastIndexOf("."));

    if (uriFragmentToMedia == null) {
        // use the newFileBase as a starting point...
        uriFragmentToMedia = uriFragmentNewFileBase + extension;
    }

    // adjust the mediaPath (destination) to have the same extension
    // and delete any existing file.
    File f = ODKFileUtils.getAsFile(appName, uriFragmentToMedia);
    File sourceMedia = new File(f.getParentFile(),
            f.getName().substring(0, f.getName().lastIndexOf('.')) + extension);
    uriFragmentToMedia = ODKFileUtils.asUriFragment(appName, sourceMedia);
    deleteMedia();

    try {
        FileUtils.copyFile(source, sourceMedia);
    } catch (IOException e) {
        WebLogger.getLogger(appName).e(t, ERROR_COPY_FILE + sourceMedia.getAbsolutePath());
        Toast.makeText(this, R.string.media_save_failed, Toast.LENGTH_SHORT).show();
        deleteMedia();
        setResult(Activity.RESULT_CANCELED);
        finish();
        return;
    }

    if (sourceMedia.exists()) {
        // Add the copy to the content provier
        ContentValues values = new ContentValues(6);
        values.put(Video.Media.TITLE, sourceMedia.getName());
        values.put(Video.Media.DISPLAY_NAME, sourceMedia.getName());
        values.put(Video.Media.DATE_ADDED, System.currentTimeMillis());
        values.put(Video.Media.DATA, sourceMedia.getAbsolutePath());

        Uri MediaURI = getApplicationContext().getContentResolver().insert(Video.Media.EXTERNAL_CONTENT_URI,
                values);
        WebLogger.getLogger(appName).i(t, "Inserting VIDEO returned uri = " + MediaURI.toString());
        uriFragmentToMedia = ODKFileUtils.asUriFragment(appName, sourceMedia);
        WebLogger.getLogger(appName).i(t, "Setting current answer to " + sourceMedia.getAbsolutePath());

        // Need to have this ugly code to account for 
        // a bug in the Nexus 7 on 4.3 not returning the mediaUri in the data
        // of the intent - uri in this case is a file 
        int delCount = 0;
        if (NEXUS7.equals(android.os.Build.MODEL) && Build.VERSION.SDK_INT == 18) {
            File fileToDelete = new File(mediaUri.getPath());
            delCount = fileToDelete.delete() ? 1 : 0;
        } else {
            delCount = getApplicationContext().getContentResolver().delete(mediaUri, null, null);
        }
        WebLogger.getLogger(appName).i(t,
                "Deleting original capture of file: " + mediaUri.toString() + " count: " + delCount);
    } else {
        WebLogger.getLogger(appName).e(t, "Inserting Video file FAILED");
    }

    /*
     * We saved the audio to the instance directory. Verify that it is there...
     */
    returnResult();
    return;
}