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: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);
    }//from w  ww.j av  a 2s . 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:edu.auburn.ppl.cyclecolumbus.TripUploader.java

/******************************************************************************************
 * Retrieves the app version of the phone
 ******************************************************************************************
 * @return app version//w w w  . jav  a  2  s .  c o m
 ******************************************************************************************/
public String getAppVersion() {
    String versionName = "";
    int versionCode = 0;

    try {
        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.silentcircle.silenttext.util.DeviceUtils.java

public static String getModel() {
    String model = System.getProperty("ro.product.model");
    return model == null ? android.os.Build.MODEL : model;
}

From source file:com.clough.android.androiddbviewer.ADBVApplication.java

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

    // Getting user configured(custom) SQLiteOpenHelper instance.
    sqliteOpenHelper = getDataBase();/* ww  w  .ja v a2 s .  c om*/

    // getDataBase() could return a null
    if (sqliteOpenHelper != null) {

        // Background operation of creating the server socket.
        new Thread(new Runnable() {
            @Override
            public void run() {
                try {

                    // Server socket re create when device is being disconnected or
                    // when AndroidDBViewer desktop application is being closed.
                    // Creating server socket will exit when
                    // android application runs in low memory or when
                    // android application being terminated due some reasons.
                    l1: while (flag) {
                        serverSocket = new ServerSocket(1993);
                        socket = serverSocket.accept();
                        br = new BufferedReader(new InputStreamReader(socket.getInputStream()));
                        pw = new PrintWriter(socket.getOutputStream(), true);

                        // Keeps a continuous communication between android application and
                        // AndroidDBViewer desktop application through IO streams of the accepted socket connection.
                        // There will be continuous data parsing between desktop application and android application.
                        // Identification of device being disconnected or desktop application being closed will be determined
                        // only when there is a NULL data being received.
                        l2: while (flag) {

                            // Format of the parsing data string is JSON, a content of a 'Data' instance
                            String requestJSONString = br.readLine();

                            if (requestJSONString == null) {

                                // Received a null response from desktop application, due to disconnecting the
                                // device or closing the AndroidDBViewer desktop application.
                                // Therefore, closing all current connections and streams to re create the server
                                // socket so that desktop application can connect in it's next run.

                                // Device disconnection doesn't produce an IOException.
                                // Also, even after calling
                                // socket.close(), socket.shutdownInput() and socket.shutdownOutput()
                                // within a shutdown hook in desktop application, the socket connection
                                // in this async task always gives
                                // socket.isConnected() as 'true' ,
                                // socket.isClosed() as 'false' ,
                                // socket.isInputShutdown() as 'false' and
                                // socket.isOutputShutdown() as 'false' .
                                // But, bufferedReader.readLine() starts returning 'null' continuously.
                                // So, inorder to desktop application to connect with the device again,
                                // there should be a ServerSocket waiting to accept a socket connection, in device.
                                closeConnection();
                                continue l1;
                            } else {

                                // Received a valid response from the desktop application.
                                Data data;
                                try {

                                    // Converting received request to a 'Data' instance.
                                    data = new Data(new JSONObject(requestJSONString));
                                    int status = data.getStatus();
                                    if (status == Data.CONNECTION_REQUEST) {

                                        // Very first request from desktop application to
                                        // establish the connection and setting the response as
                                        // connection being accepted.
                                        data.setStatus(Data.CONNECTION_ACCEPTED);
                                    } else if (status == Data.LIVE_CONNECTION) {

                                        // When there is no user interaction in desktop application,
                                        // data being passed from desktop application to android
                                        // application with the status of LIVE_CONNECTION, and the
                                        // same data send again to the desktop application from android application,
                                        // to notify that connection is still alive.
                                        // This exchange won't change until  there is a request from
                                        // desktop application with a different status.
                                    } else if (status == Data.QUERY) {

                                        // Requesting to perform a query execution.

                                        String result = "No result";
                                        try {

                                            // Performing select, insert, delete and update queries.
                                            Cursor cursor = sqliteOpenHelper.getWritableDatabase()
                                                    .rawQuery(data.getQuery(), null);

                                            // Flag to identify the firs move of the cursor
                                            boolean firstTime = true;

                                            int columnCount = 0;

                                            // JSONArray to hold the all JSONObjects, created per every row
                                            // of the result returned, executing the given query.
                                            JSONArray jsonArray = new JSONArray();

                                            // Moving the cursor to the next row of retrieved result
                                            // after executing the requested query.
                                            while (cursor.moveToNext()) {

                                                if (firstTime) {

                                                    // Column count of the result returned, executing the given query.
                                                    columnCount = cursor.getColumnCount();
                                                    firstTime = false;
                                                }

                                                // JOSNObject to hold the values of a single row
                                                JSONObject jsonObject = new JSONObject();
                                                for (int i = 0; i < columnCount; i++) {
                                                    int columnType = cursor.getType(i);
                                                    String columnName = cursor.getColumnName(i);
                                                    if (columnType == Cursor.FIELD_TYPE_STRING) {
                                                        jsonObject.put(columnName, cursor.getString(i));
                                                    } else if (columnType == Cursor.FIELD_TYPE_BLOB) {
                                                        jsonObject.put(columnName,
                                                                cursor.getBlob(i).toString());
                                                    } else if (columnType == Cursor.FIELD_TYPE_FLOAT) {
                                                        jsonObject.put(columnName,
                                                                String.valueOf(cursor.getFloat(i)));
                                                    } else if (columnType == Cursor.FIELD_TYPE_INTEGER) {
                                                        jsonObject.put(columnName,
                                                                String.valueOf(cursor.getInt(i)));
                                                    } else if (columnType == Cursor.FIELD_TYPE_NULL) {
                                                        jsonObject.put(columnName, "NULL");
                                                    } else {
                                                        jsonObject.put(columnName, "invalid type");
                                                    }
                                                }
                                                jsonArray.put(jsonObject);
                                            }
                                            result = jsonArray.toString();
                                            cursor.close();
                                        } catch (Exception e) {

                                            // If SQL error is occurred when executing the requested query,
                                            // error content will be the response to the desktop application.
                                            StringWriter sw = new StringWriter();
                                            PrintWriter epw = new PrintWriter(sw);
                                            e.printStackTrace(epw);
                                            result = sw.toString();
                                            epw.close();
                                            sw.close();
                                        } finally {
                                            data.setResult(result);
                                        }
                                    } else if (status == Data.DEVICE_NAME) {

                                        // Requesting device information
                                        data.setResult(Build.BRAND + " " + Build.MODEL);
                                    } else if (status == Data.APPLICATION_ID) {

                                        // Requesting application id (package name)
                                        data.setResult(getPackageName());
                                    } else if (status == Data.DATABASE_NAME) {

                                        // Requesting application database name.
                                        // Will provide the database name according
                                        // to the SQLiteOpenHelper user provided
                                        data.setResult(sqliteOpenHelper.getDatabaseName());
                                    } else {

                                        // Unidentified request state.
                                        closeConnection();
                                        continue l1;
                                    }
                                    String responseJSONString = data.toJSON().toString();
                                    pw.println(responseJSONString);
                                } catch (JSONException e) {

                                    // Response couldn't convert to a 'Data' instance.
                                    // Desktop application will be notified to close the application.
                                    closeConnection();
                                    continue l1;
                                }
                            }
                        }
                    }
                } catch (IOException e) {
                    // Cannot create a server socket. Letting background process to end.
                }
            }
        }).start();
    }
}

From source file:de.da_sense.moses.client.abstraction.HardwareAbstraction.java

/**
 * This method reads the sensors currently chosen by the user
 * @return the actual Hardwareinfo/* w  ww .  jav  a 2 s.  c om*/
 */
private HardwareInfo retrieveHardwareParameters() {
    // *** SENDING SET_HARDWARE_PARAMETERS REQUEST TO SERVER ***//
    LinkedList<Integer> sensors = new LinkedList<Integer>();
    SensorManager s = (SensorManager) mContext.getSystemService(Context.SENSOR_SERVICE);
    for (Sensor sen : s.getSensorList(Sensor.TYPE_ALL)) {
        sensors.add(sen.getType());
    }
    return new HardwareInfo(extractDeviceIdFromSharedPreferences(), extractDeviceNameFromSharedPreferences(),
            Build.MANUFACTURER, Build.MODEL, Build.VERSION.SDK_INT, sensors);
}

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;//from  w w w  .  j av  a 2  s.  c  om
    }

    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();
    }
}

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);//from   w w  w  .ja  va  2  s  . co  m
    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.untappedkegg.rally.home.ActivityMain.java

private void sendFeedback() {
    List<Intent> targetedShareIntents = new ArrayList<Intent>();

    final String emailMsg = String.format(
            "App Version: %s\nAndroid: %s : %s\nDevice: %s \nPlease leave the above lines for debugging purposes. Thank you!\n\n",
            BuildConfig.VERSION_NAME, Build.VERSION.SDK_INT, Build.VERSION.RELEASE,
            /*Build.FINGERPRINT,*/ Build.MODEL);

    // Google+/* w  ww  .j a  v a  2  s  . co  m*/
    ArrayList<Person> recipients = new ArrayList<Person>();
    recipients.add(PlusShare.createPerson("109961307643513437237", BuildConfig.DEV_NAME));
    targetedShareIntents
            .add(new PlusShare.Builder(this).setType("text/plain").setRecipients(recipients).getIntent());

    // Email
    try {
        targetedShareIntents.add(
                CommonIntents.getShareIntent("email", "Feedback: " + getString(R.string.app_name), emailMsg)
                        .putExtra(Intent.EXTRA_EMAIL, "UntappedKegg@gmail.com"));
    } catch (Exception e) {
    }

    try {
        targetedShareIntents.add(
                CommonIntents.getShareIntent("gmail", "Feedback: " + getString(R.string.app_name), emailMsg)
                        .putExtra(Intent.EXTRA_EMAIL, "UntappedKegg@gmail.com"));
    } catch (Exception e) {
    }

    // Twitter
    Intent twitterIntent = CommonIntents.getShareIntent("twitter", "Untapped Rally", "@UntappedKegg ");
    if (twitterIntent != null)
        targetedShareIntents.add(twitterIntent);

    // Market
    try {
        final String mPackageName = getPackageName();
        final String installer = getPackageManager().getInstallerPackageName(mPackageName);
        Intent marketIntent = null;

        if (AppState.MARKET_GOOGLE.equalsIgnoreCase(installer)) {
            marketIntent = new Intent(Intent.ACTION_VIEW, Uri.parse(AppState.APP_LINK_GOOGLE + mPackageName));
            marketIntent.addFlags(Intent.FLAG_ACTIVITY_NO_HISTORY | Intent.FLAG_ACTIVITY_MULTIPLE_TASK
                    | Intent.FLAG_ACTIVITY_NEW_TASK);

        } else if (AppState.MARKET_AMAZON.equalsIgnoreCase(installer)) {
            marketIntent = new Intent(Intent.ACTION_VIEW, Uri.parse(AppState.APP_LINK_AMAZON + mPackageName));
            marketIntent.addFlags(Intent.FLAG_ACTIVITY_NEW_TASK);
        }
        if (marketIntent != null)
            targetedShareIntents.add(marketIntent);

    } catch (Exception e) {
    }

    Intent chooserIntent = Intent.createChooser(targetedShareIntents.remove(0), "Send Feedback via:");
    chooserIntent.putExtra(Intent.EXTRA_INITIAL_INTENTS, targetedShareIntents.toArray(new Parcelable[] {}));
    startActivity(chooserIntent);

}

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

public static String getDeviceName(Context ctx) {
    if (deviceName != null)
        return deviceName;

    deviceName = ((TelephonyManager) ctx.getSystemService(Context.TELEPHONY_SERVICE)).getNetworkOperatorName();
    if (deviceName == null || deviceName.isEmpty())
        deviceName = "Wi-Fi";

    deviceName += " " + Build.MODEL;

    return deviceName.trim();
}

From source file:com.snappy.CameraCropActivity.java

@Override
public void onConfigurationChanged(Configuration newConfig) {
    super.onConfigurationChanged(newConfig);

    String pManufacturer = android.os.Build.MANUFACTURER;
    String pModel = android.os.Build.MODEL;

    if ("GT-I9300".equals(pModel) && "samsung".equals(pManufacturer)) {

        RelativeLayout main = (RelativeLayout) findViewById(R.id.relativeLayout_main);
        main.invalidate();// w  w w.j  a  va2 s  .  c om

        setContentView(R.layout.activity_camera_crop);

        mImageView = (CroppedImageView) findViewById(R.id.ivCameraCropPhoto);
        mImageView.setDrawingCacheEnabled(true);

        scaleView();

        // Cancel button
        findViewById(R.id.btnCameraCancel).setOnClickListener(new OnClickListener() {

            @Override
            public void onClick(View v) {

                finish();
                if (getIntent().getStringExtra("type").equals("gallery")) {
                    Intent intent = new Intent(CameraCropActivity.this, CameraCropActivity.class);
                    intent.putExtra("type", "gallery");
                    startActivity(intent);
                } else {
                    Intent intent = new Intent(CameraCropActivity.this, CameraCropActivity.class);
                    intent.putExtra("type", "camera");
                    startActivity(intent);
                }
            }
        });

        // Next button
        findViewById(R.id.btnCameraOk).setOnClickListener(new OnClickListener() {

            @Override
            public void onClick(View v) {
                Bitmap resizedBitmap = getBitmapFromView(mImageView);

                ByteArrayOutputStream bs = new ByteArrayOutputStream();
                resizedBitmap.compress(Bitmap.CompressFormat.JPEG, 100, bs);

                if (saveBitmapToFile(resizedBitmap, mFilePath) == true) {

                    if (mForProfile == true) {
                        MyProfileActivity.gProfileImage = getBitmapFromView(mImageView);
                        MyProfileActivity.gProfileImagePath = mFilePath;
                    } else if (mForGroup == true) {
                        CreateGroupActivity.gGroupImage = getBitmapFromView(mImageView);
                        CreateGroupActivity.gGroupImagePath = mFilePath;
                    } else if (mForGroupUpdate == true) {
                        GroupProfileActivity.gGroupImage = getBitmapFromView(mImageView);
                        GroupProfileActivity.gGroupImagePath = mFilePath;
                    } else {
                        fileUploadAsync(mFilePath);

                        //                           new FileUploadAsync(CameraCropActivity.this)
                        //                                 .execute(mFilePath);
                        // new
                        // SendMessageAsync(getApplicationContext(),
                        // SendMessageAsync.TYPE_PHOTO)
                        // .execute(resizedBitmap);
                    }
                } else {
                    Toast.makeText(CameraCropActivity.this, R.string.cameracrop_imagesend_failed,
                            Toast.LENGTH_LONG).show();
                }

            }
        });

        File file = new File(_path);
        boolean exists = file.exists();
        if (exists)
            onPhotoTaken(_path);
        else
            Toast.makeText(getBaseContext(), R.string.cameracrop_image_fatalerror, Toast.LENGTH_SHORT).show();
    }

}