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:at.alladin.rmbt.android.util.InformationCollector.java

private void getClientInfo() {
    final String tmpuuid = ConfigHelper.getUUID(context);

    if (tmpuuid == null || tmpuuid.length() == 0)
        fullInfo.setProperty("UUID", "");
    else/*from w  ww . ja  v a  2s .  co m*/
        fullInfo.setProperty("UUID", tmpuuid);

    fullInfo.setProperty("PLATTFORM", PLATTFORM_NAME);

    fullInfo.setProperty("OS_VERSION",
            android.os.Build.VERSION.RELEASE + "(" + android.os.Build.VERSION.INCREMENTAL + ")");

    fullInfo.setProperty("API_LEVEL", String.valueOf(android.os.Build.VERSION.SDK_INT));

    fullInfo.setProperty("DEVICE", android.os.Build.DEVICE);

    fullInfo.setProperty("MODEL", android.os.Build.MODEL);

    fullInfo.setProperty("PRODUCT", android.os.Build.PRODUCT);

    fullInfo.setProperty("NETWORK_TYPE", String.valueOf(getNetwork()));

    if (connManager != null) {
        final NetworkInfo activeNetworkInfo = connManager.getActiveNetworkInfo();
        if (activeNetworkInfo != null)
            fullInfo.setProperty("TELEPHONY_NETWORK_IS_ROAMING", String.valueOf(activeNetworkInfo.isRoaming()));
    }

    PackageInfo pInfo;
    String clientVersion = "";
    try {
        pInfo = context.getPackageManager().getPackageInfo(context.getPackageName(), 0);
        clientVersion = pInfo.versionName;
    } catch (final NameNotFoundException e) {
        // e1.printStackTrace();
        Log.e(DEBUG_TAG, "version of the application cannot be found", e);
    }

    fullInfo.setProperty("CLIENT_NAME", Config.RMBT_CLIENT_NAME);
    fullInfo.setProperty("CLIENT_SOFTWARE_VERSION", clientVersion);
}

From source file:com.www.avtovokzal.org.MainActivity.java

private void sendPhoneInformationToServer() {
    String version = null;/*w w  w  .j a v  a2  s  .  c o m*/
    PackageInfo packageInfo = null;

    try {
        packageInfo = getPackageManager().getPackageInfo(getPackageName(), 0);
    } catch (PackageManager.NameNotFoundException e) {
        e.printStackTrace();
    }

    String manufacturer = Uri.encode(Build.MANUFACTURER);
    String model = Uri.encode(Build.MODEL);
    String device = Uri.encode(Build.DEVICE);
    String board = Uri.encode(Build.BOARD);
    String brand = Uri.encode(Build.BRAND);
    String display = Uri.encode(Build.DISPLAY);
    String id = Uri.encode(Build.ID);
    String product = Uri.encode(Build.PRODUCT);
    String release = Uri.encode(Build.VERSION.RELEASE);

    if (packageInfo != null) {
        version = Uri.encode(packageInfo.versionName);
    }

    if (Constants.LOG_ON) {
        Log.v(TAG, "1: " + manufacturer + " 2: " + model + " 3: " + device + " 4: " + board + " 5: " + brand
                + " 6: " + display + " 7: " + id + " 8: " + product + " 9: " + release + " 10: " + version);
    }

    String url = "http://www.avtovokzal.org/php/app/sendPhoneInformation.php?manufacturer=" + manufacturer
            + "&model=" + model + "&device=" + device + "&board=" + board + "&brand=" + brand + "&display="
            + display + "&build_id=" + id + "&product=" + product + "&release_number=" + release + "&version="
            + version;

    if (isOnline()) {
        StringRequest strReq = new StringRequest(Request.Method.GET, url, new Response.Listener<String>() {
            @Override
            public void onResponse(String response) {
            }
        }, new Response.ErrorListener() {
            @Override
            public void onErrorResponse(VolleyError error) {
                if (Constants.LOG_ON)
                    VolleyLog.d(TAG, "Error: " + error.getMessage());
            }
        });
        // ? TimeOut, Retry
        strReq.setRetryPolicy(new DefaultRetryPolicy(DefaultRetryPolicy.DEFAULT_TIMEOUT_MS, 3,
                DefaultRetryPolicy.DEFAULT_BACKOFF_MULT));
        // ? ?  
        AppController.getInstance().addToRequestQueue(strReq);
    } else {
        callErrorActivity();
    }
}

From source file:com.otaupdater.utils.Utils.java

public static String getDevice() {
    if (device != null)
        return device;

    device = Build.DEVICE.toLowerCase(Locale.US);

    return device;
}

From source file:com.stfalcon.contentmanager.ContentManager.java

/**
 * Check device model and return is need to set predefined camera uri
 *///from w w w .ja  v  a2  s  . c  o m
private boolean isSetPreDefinedCameraUri() {
    boolean setPreDefinedCameraUri = false;

    // NOTE: Do NOT SET: intent.putExtra(MediaStore.EXTRA_OUTPUT, cameraPicUri)
    // on Samsung Galaxy S2/S3/.. for the following reasons:
    // 1.) it will break the correct picture orientation
    // 2.) the photo will be stored in two locations (the given path and, additionally, in the MediaStore)
    String manufacturer = Build.MANUFACTURER.toLowerCase(Locale.ENGLISH);
    String model = Build.MODEL.toLowerCase(Locale.ENGLISH);
    String buildType = Build.TYPE.toLowerCase(Locale.ENGLISH);
    String buildDevice = Build.DEVICE.toLowerCase(Locale.ENGLISH);
    String buildId = Build.ID.toLowerCase(Locale.ENGLISH);
    //            String sdkVersion = android.os.Build.VERSION.RELEASE.toLowerCase(Locale.ENGLISH);

    if (!(manufacturer.contains("samsung")) && !(manufacturer.contains("sony"))) {
        setPreDefinedCameraUri = true;
    }
    if (manufacturer.contains("samsung") && model.contains("galaxy nexus")) { //TESTED
        setPreDefinedCameraUri = true;
    }
    if (manufacturer.contains("samsung") && model.contains("gt-n7000") && buildId.contains("imm76l")) { //TESTED
        setPreDefinedCameraUri = true;
    }

    if (buildType.contains("userdebug") && buildDevice.contains("ariesve")) { //TESTED
        setPreDefinedCameraUri = true;
    }
    if (buildType.contains("userdebug") && buildDevice.contains("crespo")) { //TESTED
        setPreDefinedCameraUri = true;
    }
    if (buildType.contains("userdebug") && buildDevice.contains("gt-i9100")) { //TESTED
        setPreDefinedCameraUri = true;
    }

    ///////////////////////////////////////////////////////////////////////////
    // TEST
    if (manufacturer.contains("samsung") && model.contains("sgh-t999l")) { //T-Mobile LTE enabled Samsung S3
        setPreDefinedCameraUri = true;
    }
    if (buildDevice.contains("cooper")) {
        setPreDefinedCameraUri = true;
    }
    if (buildType.contains("userdebug") && buildDevice.contains("t0lte")) {
        setPreDefinedCameraUri = true;
    }
    if (buildType.contains("userdebug") && buildDevice.contains("kot49h")) {
        setPreDefinedCameraUri = true;
    }
    if (buildType.contains("userdebug") && buildDevice.contains("t03g")) {
        setPreDefinedCameraUri = true;
    }
    if (buildType.contains("userdebug") && buildDevice.contains("gt-i9300")) {
        setPreDefinedCameraUri = true;
    }
    if (buildType.contains("userdebug") && buildDevice.contains("gt-i9195")) {
        setPreDefinedCameraUri = true;
    }
    if (buildType.contains("userdebug") && buildDevice.contains("xperia u")) {
        setPreDefinedCameraUri = true;
    }

    ///////////////////////////////////////////////////////////////////////////
    return setPreDefinedCameraUri;
}

From source file:at.alladin.rmbt.android.util.InformationCollector.java

public static JSONObject fillBasicInfo(JSONObject object, Context ctx) throws JSONException {
    object.put("plattform", PLATTFORM_NAME);
    object.put("os_version",
            android.os.Build.VERSION.RELEASE + "(" + android.os.Build.VERSION.INCREMENTAL + ")");
    object.put("api_level", String.valueOf(android.os.Build.VERSION.SDK_INT));
    object.put("device", android.os.Build.DEVICE);
    object.put("model", android.os.Build.MODEL);
    object.put("product", android.os.Build.PRODUCT);
    object.put("language", Locale.getDefault().getLanguage());
    object.put("timezone", TimeZone.getDefault().getID());
    object.put("softwareRevision", RevisionHelper.getVerboseRevision());
    PackageInfo pInfo = getPackageInfo(ctx);
    if (pInfo != null) {
        object.put("softwareVersionCode", pInfo.versionCode);
        object.put("softwareVersionName", pInfo.versionName);
    }//  w w w  . j av  a2  s. c o m
    object.put("type", at.alladin.rmbt.android.util.Config.RMBT_CLIENT_TYPE);

    if (BASIC_INFORMATION_INCLUDE_LOCATION) {
        Location loc = GeoLocation.getLastKnownLocation(ctx);
        if (loc != null) {
            JSONObject locationJson = new JSONObject();
            locationJson.put("lat", loc.getLatitude());
            locationJson.put("long", loc.getLongitude());
            locationJson.put("provider", loc.getProvider());
            if (loc.hasSpeed())
                locationJson.put("speed", loc.getSpeed());
            if (loc.hasAltitude())
                locationJson.put("altitude", loc.getAltitude());
            locationJson.put("age", System.currentTimeMillis() - loc.getTime()); //getElapsedRealtimeNanos() would be better, but require higher API-level
            if (loc.hasAccuracy())
                locationJson.put("accuracy", loc.getAccuracy());
            if (loc.hasSpeed())
                locationJson.put("speed", loc.getSpeed());
            /*
             *  would require API level 18
            if (loc.isFromMockProvider())
               locationJson.put("mock",loc.isFromMockProvider());
            */
            object.put("location", locationJson);
        }
    }

    InformationCollector infoCollector = null;

    if (ctx instanceof RMBTMainActivity) {
        Fragment curFragment = ((RMBTMainActivity) ctx).getCurrentFragment();
        if (curFragment != null) {
            if (curFragment instanceof RMBTMainMenuFragment) {
                infoCollector = ((RMBTMainMenuFragment) curFragment).getInformationCollector();
            }
        }
    }

    if (BASIC_INFORMATION_INCLUDE_LAST_SIGNAL_ITEM && (infoCollector != null)) {
        SignalItem signalItem = infoCollector.getLastSignalItem();
        if (signalItem != null) {
            object.put("last_signal_item", signalItem.toJson());
        } else {
            object.put("last_signal_item", JSONObject.NULL);
        }
    }

    return object;
}

From source file:org.protocoderrunner.apprunner.api.PDevice.java

@ProtoMethod(description = "Get some device information", example = "")
@ProtoMethodParam(params = { "" })
public DeviceInfo info() {
    DeviceInfo deviceInfo = new DeviceInfo();

    // density dpi
    DisplayMetrics metrics = new DisplayMetrics();

    //TODO reenable this
    //contextUi.get().getWindowManager().getDefaultDisplay().getMetrics(metrics);
    deviceInfo.screenDpi = metrics.densityDpi;

    // id/*from ww w . j a v a2 s .c o  m*/
    deviceInfo.androidId = Secure.getString(getContext().getContentResolver(), Secure.ANDROID_ID);

    // imei
    deviceInfo.imei = ((TelephonyManager) getContext().getSystemService(Context.TELEPHONY_SERVICE))
            .getDeviceId();

    deviceInfo.versionRelease = Build.VERSION.RELEASE;
    deviceInfo.versionRelease = Build.VERSION.INCREMENTAL;
    deviceInfo.sdk = Build.VERSION.SDK;
    deviceInfo.board = Build.BOARD;
    deviceInfo.brand = Build.BRAND;
    deviceInfo.device = Build.DEVICE;
    deviceInfo.fingerPrint = Build.FINGERPRINT;
    deviceInfo.host = Build.HOST;
    deviceInfo.id = Build.ID;
    deviceInfo.cpuAbi = Build.CPU_ABI;
    deviceInfo.cpuAbi2 = Build.CPU_ABI2;

    return deviceInfo;
}

From source file:ee.ioc.phon.android.speak.Utils.java

public static String makeUserAgentComment(String tag, String versionName, String caller) {
    return tag + "/" + versionName + "; " + Build.MANUFACTURER + "/" + Build.DEVICE + "/" + Build.DISPLAY + "; "
            + caller;//ww  w  .  ja  v a2 s .c  o  m
}

From source file:com.chummy.jezebel.material.dark.activities.Main.java

@Override
protected void onCreate(Bundle savedInstanceState) {
    super.onCreate(savedInstanceState);
    setContentView(R.layout.activity_main);

    context = this;
    mPrefs = new Preferences(Main.this);

    Toolbar toolbar = (Toolbar) findViewById(R.id.toolbar);
    setSupportActionBar(toolbar);/*  w  w w  . ja v  a  2s . com*/
    getSupportActionBar().setDisplayHomeAsUpEnabled(true);

    thaApp = getResources().getString(R.string.app_name);
    thaHome = getResources().getString(R.string.section_one);
    thaPreviews = getResources().getString(R.string.section_two);
    thaApply = getResources().getString(R.string.section_three);
    thaWalls = getResources().getString(R.string.section_four);
    thaRequest = getResources().getString(R.string.section_five);
    thaCredits = getResources().getString(R.string.section_seven);
    thaTesters = getResources().getString(R.string.section_eight);
    thaWhatIsThemed = getResources().getString(R.string.section_nine);
    thaContactUs = getResources().getString(R.string.section_ten);
    thaLogcat = getResources().getString(R.string.section_eleven);
    thaFAQ = getResources().getString(R.string.section_twelve);
    thaHelp = getResources().getString(R.string.section_thirteen);
    thaAbout = getResources().getString(R.string.section_fourteen);
    thaIconPack = getResources().getString(R.string.section_fifteen);
    thaFullChangelog = getResources().getString(R.string.section_sixteen);
    thaRebuild = getResources().getString(R.string.section_seventeen);

    drawerVersion = getResources().getString(R.string.version_code);

    currentItem = 1;

    headerResult = new AccountHeader().withActivity(this).withHeaderBackground(R.drawable.header)
            .withSelectionFirstLine(getResources().getString(R.string.app_name))
            .withSelectionSecondLine(drawerVersion).withSavedInstance(savedInstanceState).withHeightDp(120)
            .build();

    enable_features = mPrefs.isFeaturesEnabled();
    firstrun = mPrefs.isFirstRun();

    result = new Drawer().withActivity(this).withToolbar(toolbar).withAccountHeader(headerResult)
            .withHeaderDivider(false).withDrawerWidthDp(400)
            .addDrawerItems(new SectionDrawerItem().withName("Main"),
                    new PrimaryDrawerItem().withName(thaHome).withIcon(GoogleMaterial.Icon.gmd_home)
                            .withIdentifier(1),
                    new PrimaryDrawerItem().withName(thaIconPack)
                            .withIcon(GoogleMaterial.Icon.gmd_picture_in_picture)
                            .withDescription("This applies icon pack 'Whicons'.").withCheckable(false)
                            .withIdentifier(11),
                    new PrimaryDrawerItem().withName(thaFullChangelog)
                            .withIcon(GoogleMaterial.Icon.gmd_wrap_text)
                            .withDescription("Complete changelog of Dark Material.").withCheckable(false)
                            .withIdentifier(12),
                    new DividerDrawerItem(), new SectionDrawerItem().withName("Information"),
                    new PrimaryDrawerItem().withName(thaAbout).withIcon(GoogleMaterial.Icon.gmd_info_outline)
                            .withDescription("Basic information on the theme.").withIdentifier(10),
                    new PrimaryDrawerItem().withName(thaWhatIsThemed).withIcon(GoogleMaterial.Icon.gmd_warning)
                            .withDescription("List of overlaid applications.").withIdentifier(3),
                    new PrimaryDrawerItem().withName(thaFAQ).withIcon(GoogleMaterial.Icon.gmd_question_answer)
                            .withDescription("Common questions with answers.").withIdentifier(8),
                    new DividerDrawerItem(), new SectionDrawerItem().withName("Tools & Utilities"),
                    new PrimaryDrawerItem().withName(thaRebuild).withIcon(GoogleMaterial.Icon.gmd_sync)
                            .withDescription("A rebuild a day keeps the RRs away!").withCheckable(false)
                            .withBadge("ROOT ").withIdentifier(13),
                    new PrimaryDrawerItem().withName(thaLogcat).withIcon(GoogleMaterial.Icon.gmd_bug_report)
                            .withDescription("System level log recording.").withCheckable(false)
                            .withBadge("ROOT ").withIdentifier(7),
                    new DividerDrawerItem(), new SectionDrawerItem().withName("The Developers"),
                    new PrimaryDrawerItem().withName(thaCredits).withIcon(GoogleMaterial.Icon.gmd_people)
                            .withDescription("chummy development team").withIdentifier(5),
                    new PrimaryDrawerItem().withName(thaTesters).withIcon(GoogleMaterial.Icon.gmd_star)
                            .withDescription("The people who keep the team updated.").withIdentifier(4),
                    new DividerDrawerItem(), new SectionDrawerItem().withName("Contact"),
                    new SecondaryDrawerItem().withName(thaContactUs).withIcon(GoogleMaterial.Icon.gmd_mail)
                            .withCheckable(false).withIdentifier(6),
                    new SecondaryDrawerItem().withName(thaHelp).withIcon(GoogleMaterial.Icon.gmd_help)
                            .withCheckable(true).withIdentifier(9))
            .withOnDrawerItemClickListener(new Drawer.OnDrawerItemClickListener() {
                @Override
                public void onItemClick(AdapterView<?> parent, View view, int position, long id,
                        IDrawerItem drawerItem) {

                    if (drawerItem != null) {

                        switch (drawerItem.getIdentifier()) {
                        case 1:
                            switchFragment(1, thaApp, "Home");
                            break;
                        case 2:
                            ConnectivityManager cm = (ConnectivityManager) context
                                    .getSystemService(Context.CONNECTIVITY_SERVICE);
                            NetworkInfo activeNetwork = cm.getActiveNetworkInfo();
                            boolean isConnected = activeNetwork != null
                                    && activeNetwork.isConnectedOrConnecting();

                            if (isConnected) {
                                switchFragment(2, thaWalls, "Wallpapers");
                            } else {
                                showNotConnectedDialog();
                            }
                            break;
                        case 3:
                            switchFragment(3, thaWhatIsThemed, "WhatIsThemed");
                            break;
                        case 4:
                            switchFragment(4, thaTesters, "Testers");
                            break;
                        case 5:
                            switchFragment(5, thaCredits, "Credits");
                            break;
                        case 6:
                            StringBuilder emailBuilder = new StringBuilder();
                            Intent intent = new Intent(Intent.ACTION_VIEW,
                                    Uri.parse("mailto:" + getResources().getString(R.string.email_id)));
                            if (!isAppInstalled("org.cyanogenmod.theme.chooser")) {
                                if (!isAppInstalled("com.cyngn.theme.chooser")) {
                                    if (!isAppInstalled("com.lovejoy777.rroandlayersmanager")) {
                                        intent.putExtra(Intent.EXTRA_SUBJECT,
                                                getResources().getString(R.string.email_subject));
                                    } else {
                                        intent.putExtra(Intent.EXTRA_SUBJECT,
                                                getResources().getString(R.string.email_subject_rro));
                                    }
                                } else {
                                    intent.putExtra(Intent.EXTRA_SUBJECT,
                                            getResources().getString(R.string.email_subject_cos));
                                }
                            } else {
                                intent.putExtra(Intent.EXTRA_SUBJECT,
                                        getResources().getString(R.string.email_subject_cm));
                            }
                            emailBuilder.append("\n \n \nOS Version: " + System.getProperty("os.version") + "("
                                    + Build.VERSION.INCREMENTAL + ")");
                            emailBuilder.append("\nOS API Level: " + Build.VERSION.SDK_INT + " ("
                                    + Build.VERSION.RELEASE + ") " + "[" + Build.ID + "]");
                            emailBuilder.append("\nDevice: " + Build.DEVICE);
                            emailBuilder.append("\nManufacturer: " + Build.MANUFACTURER);
                            emailBuilder.append(
                                    "\nModel (and Product): " + Build.MODEL + " (" + Build.PRODUCT + ")");
                            if (!isAppInstalled("org.cyanogenmod.theme.chooser")) {
                                if (!isAppInstalled("com.cyngn.theme.chooser")) {
                                    if (!isAppInstalled("com.lovejoy777.rroandlayersmanager")) {
                                        emailBuilder.append("\nTheme Engine: Not Available");
                                    } else {
                                        emailBuilder.append("\nTheme Engine: Layers Manager (RRO)");
                                    }
                                } else {
                                    emailBuilder.append("\nTheme Engine: Cyanogen OS Theme Engine");
                                }
                            } else {
                                emailBuilder.append("\nTheme Engine: CyanogenMod Theme Engine");
                            }
                            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 7:
                            if (Shell.SU.available()) {
                                if (!isAppInstalled("com.tooleap.logcat")) {
                                    if (!isAppInstalled("com.nolanlawson.logcat")) {
                                        Intent logcat = new Intent(Intent.ACTION_VIEW, Uri.parse(
                                                getResources().getString(R.string.play_store_link_logcat)));
                                        startActivity(logcat);
                                    } else {
                                        Intent intent_logcat = getPackageManager()
                                                .getLaunchIntentForPackage("com.nolanlawson.logcat");
                                        Toast toast = Toast.makeText(getApplicationContext(),
                                                getResources().getString(R.string.logcat_toast),
                                                Toast.LENGTH_LONG);
                                        toast.show();
                                        startActivity(intent_logcat);
                                    }
                                } else {
                                    Intent intent_tooleap = getPackageManager()
                                            .getLaunchIntentForPackage("com.tooleap.logcat");
                                    Toast toast = Toast.makeText(getApplicationContext(),
                                            getResources().getString(R.string.logcat_toast), Toast.LENGTH_LONG);
                                    toast.show();
                                    startActivity(intent_tooleap);
                                }
                            } else {
                                Toast toast = Toast.makeText(getApplicationContext(),
                                        "Unfortunately, this feature is only available for root users.",
                                        Toast.LENGTH_LONG);
                                toast.show();
                            }
                            break;
                        case 8:
                            switchFragment(8, thaFAQ, "FAQ");
                            break;
                        case 9:
                            switchFragment(9, thaHelp, "Help");
                            break;
                        case 10:
                            switchFragment(10, thaAbout, "About");
                            break;
                        case 11:
                            Intent launch_whicons = new Intent("android.intent.action.MAIN");
                            launch_whicons.setComponent(new ComponentName("org.cyanogenmod.theme.chooser",
                                    "org.cyanogenmod.theme.chooser.ChooserActivity"));
                            launch_whicons.putExtra("pkgName", "com.whicons.iconpack");
                            Intent launch_whicons_cos = new Intent("android.intent.action.MAIN");
                            launch_whicons_cos.setComponent(new ComponentName("com.cyngn.theme.chooser",
                                    "com.cyngn.theme.chooser.ChooserActivity"));
                            launch_whicons_cos.putExtra("pkgName", "com.whicons.iconpack");
                            Intent devPlay = new Intent(Intent.ACTION_VIEW,
                                    Uri.parse(getResources().getString(R.string.play_store_whicons)));
                            Intent intent_whicons = getPackageManager()
                                    .getLaunchIntentForPackage("com.whicons.iconpack");
                            if (intent_whicons == null) {
                                startActivity(devPlay);
                            } else {
                                if (isAppInstalled("org.cyanogenmod.theme.chooser")) {
                                    startActivity(launch_whicons);
                                } else {
                                    if (isAppInstalled("com.cyngn.theme.chooser")) {
                                        Toast toast = Toast.makeText(getApplicationContext(),
                                                "Select Dark Material, click Customize and locate Default Icons. Then select Whicons and click Apply.",
                                                Toast.LENGTH_LONG);
                                        toast.show();
                                        startActivity(launch_whicons_cos);
                                    } else {
                                        startActivity(intent_whicons);
                                    }
                                }
                            }
                            break;
                        case 12:
                            fullchangelog();
                            break;
                        case 13:
                            if (Shell.SU.available()) {
                                rebuildThemeCache();
                            } else {
                                Toast toast = Toast.makeText(getApplicationContext(),
                                        "Unfortunately, this feature is only available for root users.",
                                        Toast.LENGTH_LONG);
                                toast.show();
                            }
                            break;
                        }
                    }
                }
            }).withSavedInstance(savedInstanceState).build();

    result.getListView().setVerticalScrollBarEnabled(false);

    // Check for permissions first so that we don't have any issues down the road
    int permissionCheck = ContextCompat.checkSelfPermission(getApplicationContext(),
            android.Manifest.permission.WRITE_EXTERNAL_STORAGE);
    if (permissionCheck == PackageManager.PERMISSION_GRANTED) {
        // permission already granted, allow the program to continue running
        runLicenseChecker();
    } else {
        // permission not granted, request it from the user
        ActivityCompat.requestPermissions(this,
                new String[] { android.Manifest.permission.WRITE_EXTERNAL_STORAGE },
                PERMISSIONS_REQUEST_WRITE_EXTERNAL_STORAGE);
    }

    if (savedInstanceState == null) {
        result.setSelectionByIdentifier(1);
    }

}

From source file:com.google.mist.plot.MainActivity.java

private void dumpSystemInfo() {
    File dataDir = getOrCreateSessionDir();
    File target = new File(dataDir, "system_info.txt");

    // Only write system info once.
    if (target.exists()) {
        return;/* w w w . jav a  2 s  . co m*/
    }

    try {
        Display display = getWindowManager().getDefaultDisplay();
        Point size = new Point();
        display.getSize(size);

        FileWriter fw = new FileWriter(target, true);
        fw.write(String.format("Build.DEVICE: %s\n", Build.DEVICE));
        fw.write(String.format("Build.MODEL: %s\n", Build.MODEL));
        fw.write(String.format("Build.PRODUCT: %s\n", Build.PRODUCT));
        fw.write(String.format("Build.VERSION.SDK_INT: %d\n", Build.VERSION.SDK_INT));
        fw.write(String.format("Screen resolution: %d x %d px\n", size.x, size.y));
        fw.close();
    } catch (IOException e) {
        e.printStackTrace();
    }
}