Example usage for android.os Build MANUFACTURER

List of usage examples for android.os Build MANUFACTURER

Introduction

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

Prototype

String MANUFACTURER

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

Click Source Link

Document

The manufacturer of the product/hardware.

Usage

From source file:org.adblockplus.android.AdblockPlus.java

/**
 * Returns device name in user-friendly format
 *//* ww w  .  ja va2 s  . c o m*/
public static String getDeviceName() {
    String manufacturer = Build.MANUFACTURER;
    String model = Build.MODEL;
    if (model.startsWith(manufacturer))
        return capitalize(model);
    else
        return capitalize(manufacturer) + " " + model;
}

From source file:com.hijacker.SendLogActivity.java

@Override
protected void onCreate(Bundle savedInstanceState) {
    super.onCreate(savedInstanceState);
    requestWindowFeature(Window.FEATURE_NO_TITLE);
    setFinishOnTouchOutside(false);/*from w w  w .  ja v a  2 s.co  m*/
    setContentView(R.layout.activity_send_log);

    rootView = findViewById(R.id.activity_send_log);
    userEmailView = (EditText) findViewById(R.id.email_et);
    extraView = (EditText) findViewById(R.id.extra_et);
    progressBar = findViewById(R.id.reportProgressBar);
    console = (TextView) findViewById(R.id.console);
    sendProgress = findViewById(R.id.progress);
    sendCompleted = findViewById(R.id.completed);
    sendBtn = findViewById(R.id.sendBtn);
    sendEmailBtn = findViewById(R.id.sendEmailBtn);

    userEmailView.setOnEditorActionListener(new TextView.OnEditorActionListener() {
        @Override
        public boolean onEditorAction(TextView v, int actionId, KeyEvent event) {
            if (actionId == EditorInfo.IME_ACTION_NEXT) {
                extraView.requestFocus();
                return true;
            }
            return false;
        }
    });

    busybox = getFilesDir().getAbsolutePath() + "/bin/busybox";
    stackTrace = getIntent().getStringExtra("exception");
    Log.e("HIJACKER/SendLog", stackTrace);

    pref = PreferenceManager.getDefaultSharedPreferences(SendLogActivity.this);
    pref_edit = pref.edit();
    userEmailView.setText(pref.getString("user_email", ""));

    //Load device info
    PackageManager manager = getPackageManager();
    PackageInfo info;
    try {
        info = manager.getPackageInfo(getPackageName(), 0);
        versionName = info.versionName.replace(" ", "_");
        versionCode = info.versionCode;
    } catch (PackageManager.NameNotFoundException e) {
        Log.e("HIJACKER/SendLog", e.toString());
    }
    deviceModel = Build.MODEL;
    if (!deviceModel.startsWith(Build.MANUFACTURER))
        deviceModel = Build.MANUFACTURER + " " + deviceModel;
    deviceModel = deviceModel.replace(" ", "_");

    deviceID = pref.getLong("deviceID", -1);

    new SetupTask().execute();
}

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

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

From source file:com.gsma.rcs.provisioning.local.StackProvisioning.java

@Override
public void displayRcsSettings() {
    if (sLogger.isActivated()) {
        sLogger.debug("displayRcsSettings");
    }//  w  w w.  j av a2  s.  c  o  m
    Context ctx = getContext();
    Spinner spinner = (Spinner) mRootView.findViewById(R.id.Autoconfig);
    ArrayAdapter<String> adapter = new ArrayAdapter<>(ctx, android.R.layout.simple_spinner_item, mConfigModes);
    adapter.setDropDownViewResource(android.R.layout.simple_spinner_dropdown_item);
    spinner.setAdapter(adapter);
    ConfigurationMode mode = sRcsSettings.getConfigurationMode();
    spinner.setSelection(ConfigurationMode.AUTO.equals(mode) ? 1 : 0);

    TextView textView = (TextView) mRootView.findViewById(R.id.client_vendor);
    textView.setText(Build.MANUFACTURER);

    spinner = (Spinner) mRootView.findViewById(R.id.EnableRcsSwitch);
    adapter = new ArrayAdapter<>(ctx, android.R.layout.simple_spinner_item, mEnableRcseSwitch);
    adapter.setDropDownViewResource(android.R.layout.simple_spinner_dropdown_item);
    spinner.setAdapter(adapter);
    EnableRcseSwitch rcsSwitch = sRcsSettings.getEnableRcseSwitch();
    switch (rcsSwitch) {
    case ALWAYS_SHOW:
    case ONLY_SHOW_IN_ROAMING:
        spinner.setSelection(rcsSwitch.toInt());
        break;
    default:
        spinner.setSelection(2);
    }
    mHelper.setStringEditText(R.id.SecondaryProvisioningAddress,
            RcsSettingsData.SECONDARY_PROVISIONING_ADDRESS);
    mHelper.setBoolCheckBox(R.id.SecondaryProvisioningAddressOnly,
            RcsSettingsData.SECONDARY_PROVISIONING_ADDRESS_ONLY);

    spinner = (Spinner) mRootView.findViewById(R.id.NetworkAccess);
    adapter = new ArrayAdapter<>(ctx, android.R.layout.simple_spinner_item, mNetworkAccesses);
    adapter.setDropDownViewResource(android.R.layout.simple_spinner_dropdown_item);
    spinner.setAdapter(adapter);
    NetworkAccessType access = sRcsSettings.getNetworkAccess();
    switch (access) {
    case MOBILE:
        spinner.setSelection(1);
        break;
    case WIFI:
        spinner.setSelection(2);
        break;
    case ANY:
    default:
        spinner.setSelection(0);
    }
    spinner = (Spinner) mRootView.findViewById(R.id.SipDefaultProtocolForMobile);
    adapter = new ArrayAdapter<>(ctx, android.R.layout.simple_spinner_item, SIP_PROTOCOL);
    adapter.setDropDownViewResource(android.R.layout.simple_spinner_dropdown_item);
    spinner.setAdapter(adapter);
    String sipMobile = sRcsSettings.getSipDefaultProtocolForMobile();
    if (SIP_PROTOCOL[0].equalsIgnoreCase(sipMobile)) {
        spinner.setSelection(0);
    } else if (SIP_PROTOCOL[1].equalsIgnoreCase(sipMobile)) {
        spinner.setSelection(1);
    } else {
        spinner.setSelection(2);
    }
    spinner = (Spinner) mRootView.findViewById(R.id.SipDefaultProtocolForWifi);
    adapter = new ArrayAdapter<>(ctx, android.R.layout.simple_spinner_item, SIP_PROTOCOL);
    adapter.setDropDownViewResource(android.R.layout.simple_spinner_dropdown_item);
    spinner.setAdapter(adapter);
    String sipWifi = sRcsSettings.getSipDefaultProtocolForWifi();
    if (SIP_PROTOCOL[0].equalsIgnoreCase(sipWifi)) {
        spinner.setSelection(0);
    } else if (SIP_PROTOCOL[1].equalsIgnoreCase(sipWifi)) {
        spinner.setSelection(1);
    } else {
        spinner.setSelection(2);
    }
    String[] certificates = loadCertificatesList();
    spinner = (Spinner) mRootView.findViewById(R.id.TlsCertificateRoot);
    adapter = new ArrayAdapter<>(ctx, android.R.layout.simple_spinner_item, certificates);
    adapter.setDropDownViewResource(android.R.layout.simple_spinner_dropdown_item);
    spinner.setAdapter(adapter);
    boolean found = false;
    String certRoot = sRcsSettings.getTlsCertificateRoot();
    for (int i = 0; i < certificates.length; i++) {
        if (certRoot != null && certRoot.contains(certificates[i])) {
            spinner.setSelection(i);
            found = true;
        }
    }
    if (!found) {
        spinner.setSelection(0);
        sRcsSettings.writeString(RcsSettingsData.TLS_CERTIFICATE_ROOT, "");
    }
    spinner = (Spinner) mRootView.findViewById(R.id.TlsCertificateIntermediate);
    adapter = new ArrayAdapter<>(ctx, android.R.layout.simple_spinner_item, certificates);
    adapter.setDropDownViewResource(android.R.layout.simple_spinner_dropdown_item);
    spinner.setAdapter(adapter);
    spinner.setSelection(0);
    found = false;
    String certInt = sRcsSettings.getTlsCertificateIntermediate();
    for (int i = 0; i < certificates.length; i++) {
        if (certInt != null && certInt.contains(certificates[i])) {
            spinner.setSelection(i);
            found = true;
        }
    }
    if (!found) {
        spinner.setSelection(0);
        sRcsSettings.writeString(RcsSettingsData.TLS_CERTIFICATE_INTERMEDIATE, "");
    }
    spinner = (Spinner) mRootView.findViewById(R.id.FtProtocol);
    adapter = new ArrayAdapter<>(ctx, android.R.layout.simple_spinner_item, FT_PROTOCOL);
    adapter.setDropDownViewResource(android.R.layout.simple_spinner_dropdown_item);
    spinner.setAdapter(adapter);
    FileTransferProtocol ftProtocol = sRcsSettings.getFtProtocol();
    if (FileTransferProtocol.HTTP.equals(ftProtocol)) {
        spinner.setSelection(0);
    } else {
        spinner.setSelection(1);
    }
    mHelper.setLongEditText(R.id.ImsServicePollingPeriod, RcsSettingsData.IMS_SERVICE_POLLING_PERIOD);
    mHelper.setIntEditText(R.id.SipListeningPort, RcsSettingsData.SIP_DEFAULT_PORT);
    mHelper.setLongEditText(R.id.SipTimerT1, RcsSettingsData.SIP_TIMER_T1);
    mHelper.setLongEditText(R.id.SipTimerT2, RcsSettingsData.SIP_TIMER_T2);
    mHelper.setLongEditText(R.id.SipTimerT4, RcsSettingsData.SIP_TIMER_T4);
    mHelper.setLongEditText(R.id.SipTransactionTimeout, RcsSettingsData.SIP_TRANSACTION_TIMEOUT);
    mHelper.setLongEditText(R.id.SipKeepAlivePeriod, RcsSettingsData.SIP_KEEP_ALIVE_PERIOD);
    mHelper.setIntEditText(R.id.DefaultMsrpPort, RcsSettingsData.MSRP_DEFAULT_PORT);
    mHelper.setIntEditText(R.id.DefaultRtpPort, RcsSettingsData.RTP_DEFAULT_PORT);
    mHelper.setLongEditText(R.id.MsrpTransactionTimeout, RcsSettingsData.MSRP_TRANSACTION_TIMEOUT);
    mHelper.setLongEditText(R.id.RegisterExpirePeriod, RcsSettingsData.REGISTER_EXPIRE_PERIOD);
    mHelper.setLongEditText(R.id.RegisterRetryBaseTime, RcsSettingsData.REGISTER_RETRY_BASE_TIME);
    mHelper.setLongEditText(R.id.RegisterRetryMaxTime, RcsSettingsData.REGISTER_RETRY_MAX_TIME);
    mHelper.setLongEditText(R.id.PublishExpirePeriod, RcsSettingsData.PUBLISH_EXPIRE_PERIOD);
    mHelper.setLongEditText(R.id.RevokeTimeout, RcsSettingsData.REVOKE_TIMEOUT);
    mHelper.setLongEditText(R.id.RingingPeriod, RcsSettingsData.RINGING_SESSION_PERIOD);
    mHelper.setLongEditText(R.id.SubscribeExpirePeriod, RcsSettingsData.SUBSCRIBE_EXPIRE_PERIOD);
    mHelper.setLongEditText(R.id.IsComposingTimeout, RcsSettingsData.IS_COMPOSING_TIMEOUT);
    mHelper.setLongEditText(R.id.SessionRefreshExpirePeriod, RcsSettingsData.SESSION_REFRESH_EXPIRE_PERIOD);
    mHelper.setLongEditText(R.id.CapabilityRefreshTimeout, RcsSettingsData.CAPABILITY_REFRESH_TIMEOUT);
    mHelper.setLongEditText(R.id.CapabilityExpiryTimeout, RcsSettingsData.CAPABILITY_EXPIRY_TIMEOUT);
    mHelper.setLongEditText(R.id.CapabilityPollingPeriod, RcsSettingsData.CAPABILITY_POLLING_PERIOD);
    mHelper.setBoolCheckBox(R.id.TcpFallback, RcsSettingsData.TCP_FALLBACK);
    mHelper.setBoolCheckBox(R.id.SipKeepAlive, RcsSettingsData.SIP_KEEP_ALIVE);
    mHelper.setBoolCheckBox(R.id.PermanentState, RcsSettingsData.PERMANENT_STATE_MODE);
    mHelper.setBoolCheckBox(R.id.TelUriFormat, RcsSettingsData.TEL_URI_FORMAT);
    mHelper.setBoolCheckBox(R.id.ImAlwaysOn, RcsSettingsData.IM_CAPABILITY_ALWAYS_ON);
    mHelper.setBoolCheckBox(R.id.FtAlwaysOn, RcsSettingsData.FT_CAPABILITY_ALWAYS_ON);
    mHelper.setBoolCheckBox(R.id.FtHttpAlwaysOn, RcsSettingsData.FT_HTTP_CAP_ALWAYS_ON);
    mHelper.setBoolCheckBox(R.id.InviteOnlyGroupchatSF, RcsSettingsData.GROUP_CHAT_INVITE_ONLY_FULL_SF);
    mHelper.setBoolCheckBox(R.id.ImUseReports, RcsSettingsData.IM_USE_REPORTS);
    mHelper.setBoolCheckBox(R.id.Gruu, RcsSettingsData.GRUU);
    mHelper.setBoolCheckBox(R.id.CpuAlwaysOn, RcsSettingsData.CPU_ALWAYS_ON);
    mHelper.setBoolCheckBox(R.id.SecureMsrpOverWifi, RcsSettingsData.SECURE_MSRP_OVER_WIFI);
    mHelper.setBoolCheckBox(R.id.SecureRtpOverWifi, RcsSettingsData.SECURE_RTP_OVER_WIFI);
    mHelper.setBoolCheckBox(R.id.ImeiAsDeviceId, RcsSettingsData.USE_IMEI_AS_DEVICE_ID);
    mHelper.setBoolCheckBox(R.id.ControlExtensions, RcsSettingsData.CONTROL_EXTENSIONS);
    mHelper.setBoolCheckBox(R.id.AllowExtensions, RcsSettingsData.ALLOW_EXTENSIONS);
    mHelper.setIntEditText(R.id.MaxMsrpLengthExtensions, RcsSettingsData.MAX_MSRP_SIZE_EXTENSIONS);
    mHelper.setLongEditText(R.id.MessagingCapabilitiesValidity, RcsSettingsData.MSG_CAP_VALIDITY_PERIOD);
}

From source file:org.noise_planet.noisecapture.MeasurementExport.java

/**
 * Dump measurement into the specified writer
 * @param recordId Record identifier//  w w  w  . j  av  a2s .co  m
 * @param outputStream Data output target
 * @throws IOException output error
 */
public void exportRecord(int recordId, OutputStream outputStream, boolean exportReadme) throws IOException {
    SharedPreferences sharedPref = PreferenceManager.getDefaultSharedPreferences(context);
    ZipOutputStream zipOutputStream = new ZipOutputStream(outputStream);
    Storage.Record record = measurementManager.getRecord(recordId);

    // Property file
    Properties properties = new Properties();
    String versionName = "NONE";
    int versionCode = -1;
    try {
        PackageInfo packageInfo = context.getPackageManager().getPackageInfo(context.getPackageName(), 0);
        versionName = packageInfo.versionName;
        versionCode = packageInfo.versionCode;
    } catch (PackageManager.NameNotFoundException ex) {
        LOGGER.error(ex.getLocalizedMessage(), ex);
    }
    properties.setProperty(PROP_VERSION_NAME, versionName);
    properties.setProperty(PROP_BUILD_TIME, String.valueOf(BuildConfig.TIMESTAMP));
    properties.setProperty(PROP_VERSION_INT, String.valueOf(versionCode));
    properties.setProperty(PROP_MANUFACTURER, Build.MANUFACTURER);
    properties.setProperty(PROP_PRODUCT, Build.PRODUCT);
    properties.setProperty(PROP_MODEL, Build.MODEL);
    properties.setProperty(PROP_UUID, sharedPref.getString(PROP_UUID, ""));
    properties.setProperty(Storage.Record.COLUMN_UTC, String.valueOf(record.getUtc()));
    properties.setProperty(Storage.Record.COLUMN_LEQ_MEAN,
            String.format(Locale.US, "%.02f", record.getLeqMean()));
    properties.setProperty(PROP_GAIN_CALIBRATION,
            String.format(Locale.US, "%.02f", record.getCalibrationGain()));
    properties.setProperty(Storage.Record.COLUMN_TIME_LENGTH, String.valueOf(record.getTimeLength()));
    if (record.getPleasantness() != null) {
        properties.setProperty(Storage.Record.COLUMN_PLEASANTNESS, String.valueOf(record.getPleasantness()));
    }
    List<String> tags = measurementManager.getTags(recordId);
    StringBuilder tagsString = new StringBuilder();
    for (String tag : tags) {
        if (tagsString.length() != 0) {
            tagsString.append(",");
        }
        tagsString.append(tag);
    }
    properties.setProperty(PROP_TAGS, tagsString.toString());
    zipOutputStream.putNextEntry(new ZipEntry(PROPERTY_FILENAME));
    properties.store(zipOutputStream, "NoiseCapture export header file");
    zipOutputStream.closeEntry();

    // GeoJSON file

    List<MeasurementManager.LeqBatch> records = measurementManager.getRecordLocations(recordId, false);
    // If Memory problems switch to JSONWriter
    JSONObject main = new JSONObject();

    try {
        // Add CRS
        JSONObject crs = new JSONObject();
        JSONObject crsProperty = new JSONObject();
        crsProperty.put("name", "urn:ogc:def:crs:OGC:1.3:CRS84");
        crs.put("type", "name");
        crs.put("properties", crsProperty);
        main.put("crs", crs);

        // Add measures
        main.put("type", "FeatureCollection");
        List<JSONObject> features = new ArrayList<>(records.size());
        for (MeasurementManager.LeqBatch entry : records) {
            Storage.Leq leq = entry.getLeq();
            JSONObject feature = new JSONObject();
            feature.put("type", "Feature");

            if (leq.getAccuracy() > 0) {
                // Add coordinate
                JSONObject point = new JSONObject();
                point.put("type", "Point");
                point.put("coordinates",
                        new JSONArray(Arrays.asList(leq.getLongitude(), leq.getLatitude(), leq.getAltitude())));
                feature.put("geometry", point);
            } else {
                feature.put("geometry", JSONObject.NULL);
            }

            // Add properties
            JSONObject featureProperties = new JSONObject();
            featureProperties.put(Storage.Record.COLUMN_LEQ_MEAN, entry.computeGlobalLeq());
            featureProperties.put(Storage.Leq.COLUMN_ACCURACY, leq.getAccuracy());
            featureProperties.put(Storage.Leq.COLUMN_LOCATION_UTC, leq.getLocationUTC());
            featureProperties.put(Storage.Leq.COLUMN_LEQ_UTC, leq.getLeqUtc());
            featureProperties.put(Storage.Leq.COLUMN_LEQ_ID, leq.getLeqId());
            //marker-color tag for geojson.io
            featureProperties.put("marker-color", String.format("#%06X",
                    (0xFFFFFF & Spectrogram.getColor((float) entry.computeGlobalLeq(), 45, 100))));
            if (leq.getBearing() != null) {
                featureProperties.put(Storage.Leq.COLUMN_BEARING, leq.getBearing());
            }
            if (leq.getSpeed() != null) {
                featureProperties.put(Storage.Leq.COLUMN_SPEED, leq.getSpeed());
            }
            for (Storage.LeqValue leqValue : entry.getLeqValues()) {
                featureProperties.put("leq_" + leqValue.getFrequency(), leqValue.getSpl());
            }
            feature.put("properties", featureProperties);
            features.add(feature);
        }
        main.put("features", new JSONArray(features));
        zipOutputStream.putNextEntry(new ZipEntry(GEOJSON_FILENAME));
        Writer writer = new OutputStreamWriter(zipOutputStream);
        writer.write(main.toString(2));
        writer.flush();
        zipOutputStream.closeEntry();

        if (exportReadme) {
            // Readme file
            zipOutputStream.putNextEntry(new ZipEntry(README_FILENAME));
            writer = new OutputStreamWriter(zipOutputStream);
            writer.write(context.getString(R.string.export_zip_info));
            writer.flush();
            zipOutputStream.closeEntry();
        }
    } catch (JSONException ex) {
        throw new IOException(ex);
    } finally {
        zipOutputStream.finish();
    }
}

From source file:com.urucas.deskflix.utils.Utils.java

public static String getDeviceName() {
    String manufacturer = Build.MANUFACTURER;
    String model = Build.MODEL;//from w  w w. j  a  va2  s . c om
    if (model.startsWith(manufacturer)) {
        return Utils.capitalize(model);
    } else {
        return Utils.capitalize(manufacturer) + " " + model;
    }
}

From source file:org.ciasaboark.tacere.activity.fragment.BugReportDialogFragment.java

@Nullable
@Override/*from  w ww .  j a  v a2  s .c  o  m*/
public View onCreateView(LayoutInflater inflater, ViewGroup container, Bundle savedInstanceState) {
    rootView = inflater.inflate(R.layout.activity_bug_report, container, false);

    final Spinner spinner = (Spinner) rootView.findViewById(R.id.spinner);
    // Create an ArrayAdapter using the string array and a default spinner layout
    ArrayAdapter<CharSequence> adapter = ArrayAdapter.createFromResource(getActivity(), R.array.report_types,
            android.R.layout.simple_spinner_item);
    // Specify the layout to use when the list of choices appears
    adapter.setDropDownViewResource(android.R.layout.simple_spinner_dropdown_item);
    // Apply the adapter to the spinner
    spinner.setAdapter(adapter);

    Button closeButton = (Button) rootView.findViewById(R.id.bug_report_button_cancel);
    closeButton.setOnClickListener(new View.OnClickListener() {
        @Override
        public void onClick(View v) {
            BugReportDialogFragment.this.dismiss();
        }
    });

    final Button sendButton = (Button) rootView.findViewById(R.id.bug_report_button_send);
    sendButton.setEnabled(false);
    sendButton.setVisibility(View.INVISIBLE);
    sendButton.setOnClickListener(new View.OnClickListener() {
        @Override
        public void onClick(View v) {
            sendButton.setEnabled(false);

            final ProgressBar busySpinner = (ProgressBar) rootView.findViewById(R.id.bug_report_progressbar);
            busySpinner.setVisibility(View.VISIBLE);

            EditText messageEditText = (EditText) rootView.findViewById(R.id.bug_report_message);
            final String messageText = messageEditText.getText().toString();

            EditText emailEditText = (EditText) rootView.findViewById(R.id.bug_report_email);
            String emailText = emailEditText.getText().toString();
            final String emailString = emailText.length() == 0 ? "no email address given" : emailText;

            final String spinnerSelection = spinner.getSelectedItem() == null ? "bug"
                    : spinner.getSelectedItem().toString();

            new Thread(new Runnable() {
                @Override
                public void run() {
                    boolean reportSent = false;
                    GitHubClient client = new GitHubClient();
                    client.setOAuth2Token(GitHubKeySet.GITHUB_OAUTH);

                    RepositoryService repositoryService = new RepositoryService(client);
                    try {
                        Repository repository = repositoryService.getRepository("ciasaboark", "Tacere");

                        IssueService issueService = new IssueService();
                        issueService.getClient().setOAuth2Token(GitHubKeySet.GITHUB_OAUTH);
                        Issue issue = new Issue();
                        issue.setTitle("Tacere issue submit");

                        String bodyText = "";
                        bodyText += messageText;
                        bodyText += "\n\nEmail : " + emailString;
                        bodyText += "\nAndroid Version: " + Build.VERSION.RELEASE;
                        bodyText += "\nTacere version: " + Versioning.getVersionCode();
                        bodyText += "\nDevice: " + Build.MANUFACTURER + " - " + Build.MODEL;
                        bodyText += "\nRom: " + Build.DISPLAY;

                        issue.setBody(bodyText);

                        Label label = new Label();
                        label.setName("autosubmit");
                        List<Label> labels = new ArrayList<Label>();
                        labels.add(label);

                        String reportTypeLabel;
                        switch (spinnerSelection.toLowerCase()) {
                        case "bug":
                            reportTypeLabel = "bug";
                            break;
                        case "wishlist":
                            reportTypeLabel = "wishlist";
                            break;
                        default:
                            Log.w(TAG, "unknown reportType " + spinnerSelection + ", assuming to "
                                    + "be a bug report");
                            reportTypeLabel = "bug";
                        }

                        Label reportLabel = new Label();
                        reportLabel.setName(reportTypeLabel);
                        labels.add(reportLabel);
                        issue.setLabels(labels);

                        UserService userService = new UserService(client);
                        User user = userService.getUser("ciasaboark");
                        issue.setAssignee(user);

                        try {
                            issueService.createIssue(repository, issue);
                            reportSent = true;
                        } catch (IOException e) {
                            Log.e(TAG, "unable to create issue in repository");
                        }

                    } catch (IOException e) {
                        Log.e(TAG, "unable to get list of user repositories");
                    }

                    if (reportSent) {
                        getActivity().runOnUiThread(new Runnable() {
                            public void run() {
                                Toast.makeText(getActivity(), R.string.bug_report_toast_sent, Toast.LENGTH_LONG)
                                        .show();
                                BugReportDialogFragment.this.dismiss();

                            }
                        });
                    } else {
                        getActivity().runOnUiThread(new Runnable() {
                            public void run() {
                                Toast.makeText(getActivity(), R.string.bug_report_toast_failed,
                                        Toast.LENGTH_LONG).show();
                                busySpinner.setVisibility(View.INVISIBLE);
                                sendButton.setEnabled(true);
                                sendButton.setVisibility(View.VISIBLE);
                            }
                        });
                    }
                }
            }).start();

        }
    });

    EditText messageEditText = (EditText) rootView.findViewById(R.id.bug_report_message);
    messageEditText.addTextChangedListener(new TextWatcher() {
        @Override
        public void beforeTextChanged(CharSequence s, int start, int count, int after) {
            //nothing to do here
        }

        @Override
        public void onTextChanged(CharSequence s, int start, int before, int count) {
            //nothing to do here
        }

        @Override
        public void afterTextChanged(Editable s) {
            if (s.length() > 0) {
                sendButton.setVisibility(View.VISIBLE);
                sendButton.setEnabled(true);
            } else {
                sendButton.setVisibility(View.INVISIBLE);
                sendButton.setEnabled(false);
            }
        }
    });

    return rootView;
}

From source file:com.bearstouch.android.core.InstallTracker.java

public void trackInstall(Activity activity, String app_name, String app_version_name) {

    mGTracker.trackEvent(INSTALL_TRACK_EVENT_TAG, APP_NAME_VAR, app_name, 1);
    mGTracker.trackEvent(INSTALL_TRACK_EVENT_TAG, APP_VERSION_VAR, app_version_name, 1);
    mGTracker.trackEvent(INSTALL_TRACK_EVENT_TAG, SDK_VERSION_VAR, Integer.toString(Build.VERSION.SDK_INT), 1);
    mGTracker.trackEvent(INSTALL_TRACK_EVENT_TAG, PHONE_VAR,
            Build.MANUFACTURER + " " + Build.PRODUCT + " " + Build.MODEL, 1);
    mGTracker.trackEvent(INSTALL_TRACK_EVENT_TAG, CPU_VAR, Build.CPU_ABI, 1);
    String installationSource = mContext.getPackageManager().getInstallerPackageName(mContext.getPackageName());
    mGTracker.trackEvent(INSTALL_TRACK_EVENT_TAG, INSTALLER_VAR, installationSource, 1);

    // Ecra/*from   ww w.ja  v  a2s  . c  om*/
    DisplayMetrics displayMetrics = AndroidUtil.getDisplayMetrics(activity);
    if (displayMetrics != null) {
        String Resolution = displayMetrics.widthPixels + "x" + displayMetrics.heightPixels;
        String dpis = displayMetrics.xdpi + "x" + displayMetrics.ydpi;
        mGTracker.trackEvent(INSTALL_TRACK_EVENT_TAG, "RESOLUTION", Resolution, 1);
        mGTracker.trackEvent(INSTALL_TRACK_EVENT_TAG, "DPI", dpis, 1);
    }
}

From source file:mobisocial.metrics.MusubiExceptionHandler.java

static JSONObject jsonForException(Context context, Throwable ex, boolean caught) {
    JSONObject json = new JSONObject();
    try {/*from w w  w. j  a v  a2s.  c  om*/
        Writer traceWriter = new StringWriter();
        PrintWriter printer = new PrintWriter(traceWriter);
        ex.printStackTrace(printer);
        json.put("type", "exception");
        json.put("caught", caught);
        json.put("app", context.getPackageName());
        json.put("message", ex.getMessage());
        json.put("trace", traceWriter.toString());
        json.put("timestamp", Long.toString(new Date().getTime()));

        boolean devmode = MusubiBaseActivity.isDeveloperModeEnabled(context);
        json.put("musubi_devmode", Boolean.toString(devmode));
        if (devmode) {
            IdentitiesManager im = new IdentitiesManager(App.getDatabaseSource(context));
            MIdentity id = im.getMyDefaultIdentity();
            String user = "Unknown";
            if (id != null) {
                user = UiUtil.safeNameForIdentity(id);
            }
            json.put("musubi_devmode_user_id", user);
            user = App.getMusubi(context).userForLocalDevice(null).getName();
            json.put("musubi_devmode_user_name", user);
        }
        try {
            PackageInfo info = context.getPackageManager().getPackageInfo(context.getPackageName(), 0);
            json.put("musubi_version_name", info.versionName);
            json.put("musubi_version_code", Integer.toString(info.versionCode));
        } catch (NameNotFoundException e) {
            // shouldn't happen, but not fatal.
        }
        json.put("android_api", Integer.toString(Build.VERSION.SDK_INT));
        json.put("android_release", Build.VERSION.RELEASE);
        json.put("android_model", Build.MODEL);
        json.put("android_make", Build.MANUFACTURER);
    } catch (JSONException e) {
    }
    return json;
}

From source file:om.sstvencoder.MainActivity.java

private void showErrorMessage(final String title, final String shortText, final String longText) {
    AlertDialog.Builder builder = new AlertDialog.Builder(this);
    builder.setTitle(title);//w  w  w .  j a  v  a  2s.  c o  m
    builder.setMessage(shortText);
    builder.setNeutralButton(getString(R.string.btn_ok), null);
    builder.setPositiveButton(getString(R.string.btn_send_email), new DialogInterface.OnClickListener() {
        @Override
        public void onClick(DialogInterface dialog, int which) {
            String device = Build.MANUFACTURER + ", " + Build.BRAND + ", " + Build.MODEL + ", "
                    + Build.VERSION.RELEASE;
            String text = longText + "\n\n" + BuildConfig.VERSION_NAME + ", " + device;
            Intent intent = Utility.createEmailIntent(getString(R.string.email_subject), text);
            startActivity(Intent.createChooser(intent, getString(R.string.chooser_title)));
        }
    });
    builder.show();
}