List of usage examples for android.os Build DEVICE
String DEVICE
To view the source code for android.os Build DEVICE.
Click Source Link
From source file:cz.maresmar.sfm.app.SfmApp.java
private void sendFeedback(Context context, String subject) { Timber.i("Device %s (%s) on SDK %d", Build.DEVICE, Build.MANUFACTURER, Build.VERSION.SDK_INT); File logFile = getLogFile();//from w w w .j a va2s .co m Uri logUri = FileProvider.getUriForFile(this, "cz.maresmar.sfm.FileProvider", logFile); Intent emailIntent = new Intent(Intent.ACTION_SENDTO); emailIntent.setData(Uri.parse("mailto:")); emailIntent.putExtra(Intent.EXTRA_EMAIL, new String[] { "mmrmartin+dev" + '@' + "gmail.com" }); emailIntent.putExtra(Intent.EXTRA_SUBJECT, "[sfm] " + subject); emailIntent.putExtra(Intent.EXTRA_TEXT, getString(R.string.feedback_mail_text)); emailIntent.putExtra(Intent.EXTRA_STREAM, logUri); emailIntent.setFlags(Intent.FLAG_GRANT_READ_URI_PERMISSION); List<ResolveInfo> resInfoList = getPackageManager().queryIntentActivities(emailIntent, PackageManager.MATCH_DEFAULT_ONLY); for (ResolveInfo resolveInfo : resInfoList) { String packageName = resolveInfo.activityInfo.packageName; context.grantUriPermission(packageName, logUri, Intent.FLAG_GRANT_WRITE_URI_PERMISSION | Intent.FLAG_GRANT_READ_URI_PERMISSION); } context.startActivity( Intent.createChooser(emailIntent, getString(R.string.feedback_choose_email_app_dialog))); }
From source file:com.appbackr.android.tracker.Tracker.java
/** * Generates a unique ID for the device. * //from w w w. j a v a2 s.c om * This function obtain the Unique ID from the phone. The Unique ID consist of * Build.BOARD + Build.BRAND + Build.CPU_ABI * + Build.DEVICE + Build.DISPLAY + Build.FINGERPRINT + Build.HOST * + Build.ID + Build.MANUFACTURER + Build.MODEL + Build.PRODUCT * + Build.TAGS + Build.TYPE + Build.USER; * + IMEI (GSM) or MEID/ESN (CDMA) * + Android-assigned id * * The Android ID may be changed everytime the user perform Factory Reset * I heard that IMEI values might not be unique because phone factory * might reuse IMEI values to cut cost. * * While the ID might be different from the same device, but resetting of the * Android phone should not occur that often. The values should be close * enough. * * @param c android application contact * @return unique ID as md5 hash generated of available parameters from device and cell phone service provider */ private static String getUDID(Context c) { // Get some of the hardware information String buildParams = Build.BOARD + Build.BRAND + Build.CPU_ABI + Build.DEVICE + Build.DISPLAY + Build.FINGERPRINT + Build.HOST + Build.ID + Build.MANUFACTURER + Build.MODEL + Build.PRODUCT + Build.TAGS + Build.TYPE + Build.USER; // Requires READ_PHONE_STATE TelephonyManager tm = (TelephonyManager) c.getSystemService(Context.TELEPHONY_SERVICE); // gets the imei (GSM) or MEID/ESN (CDMA) String imei = tm.getDeviceId(); // gets the android-assigned id String androidId = Secure.getString(c.getContentResolver(), Secure.ANDROID_ID); // concatenate the string String fullHash = buildParams.toString() + imei + androidId; return md5(fullHash); }
From source file:org.simlar.SimlarService.java
@Override public void onCreate() { Log.i(LOGTAG, "started on device: " + Build.DEVICE); FileHelper.init(this); mVibratorThread = new VibratorThread(this.getApplicationContext()); mRingtoneThread = new RingtoneThread(this.getApplicationContext()); mWakeLock = ((PowerManager) this.getSystemService(Context.POWER_SERVICE)) .newWakeLock(PowerManager.PARTIAL_WAKE_LOCK | PowerManager.ACQUIRE_CAUSES_WAKEUP, "SimlarWakeLock"); mWifiLock = ((WifiManager) this.getSystemService(Context.WIFI_SERVICE)) .createWifiLock(WifiManager.WIFI_MODE_FULL, "SimlarWifiLock"); startForeground(NOTIFICATION_ID, createNotification(SimlarStatus.OFFLINE)); mLinphoneThread = new LinphoneThread(this, this); IntentFilter intentFilter = new IntentFilter(); intentFilter.addAction(ConnectivityManager.CONNECTIVITY_ACTION); registerReceiver(mNetworkChangeReceiver, intentFilter); startKeepAwake();//from w ww . j a va2s .c o m mHandler.post(new Runnable() { @Override public void run() { initializeCredentials(); } }); }
From source file:com.github.javiersantos.piracychecker.LibraryUtils.java
/** * Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file * except in compliance with the License. You may obtain a copy of the License at * * http://www.apache.org/licenses/LICENSE-2.0 * * Unless required by applicable law or agreed to in writing, software distributed under the * License is distributed on an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, * either express or implied. See the License for the specific language governing permissions * and limitations under the License.//from w w w . j a v a2s. c o m * * Copyright (C) 2013, Vladislav Gingo Skoumal (http://www.skoumal.net) */ static boolean isInEmulator(boolean deepCheck) { int ratingCheckEmulator = 0; if (Build.PRODUCT.contains("sdk") || Build.PRODUCT.contains("Andy") || Build.PRODUCT.contains("ttVM_Hdragon") || Build.PRODUCT.contains("google_sdk") || Build.PRODUCT.contains("Droid4X") || Build.PRODUCT.contains("nox") || Build.PRODUCT.contains("sdk_x86") || Build.PRODUCT.contains("sdk_google") || Build.PRODUCT.contains("vbox86p")) { ratingCheckEmulator++; } if (Build.MANUFACTURER.equals("unknown") || Build.MANUFACTURER.equals("Genymotion") || Build.MANUFACTURER.contains("Andy") || Build.MANUFACTURER.contains("MIT") || Build.MANUFACTURER.contains("nox") || Build.MANUFACTURER.contains("TiantianVM")) { ratingCheckEmulator++; } if (Build.BRAND.equals("generic") || Build.BRAND.equals("generic_x86") || Build.BRAND.equals("TTVM") || Build.BRAND.contains("Andy")) { ratingCheckEmulator++; } if (Build.DEVICE.contains("generic") || Build.DEVICE.contains("generic_x86") || Build.DEVICE.contains("Andy") || Build.DEVICE.contains("ttVM_Hdragon") || Build.DEVICE.contains("Droid4X") || Build.DEVICE.contains("nox") || Build.DEVICE.contains("generic_x86_64") || Build.DEVICE.contains("vbox86p")) { ratingCheckEmulator++; } if (Build.MODEL.equals("sdk") || Build.MODEL.equals("google_sdk") || Build.MODEL.contains("Droid4X") || Build.MODEL.contains("TiantianVM") || Build.MODEL.contains("Andy") || Build.MODEL.equals("Android SDK built for x86_64") || Build.MODEL.equals("Android SDK built for x86")) { ratingCheckEmulator++; } if (Build.HARDWARE.equals("goldfish") || Build.HARDWARE.equals("vbox86") || Build.HARDWARE.contains("nox") || Build.HARDWARE.contains("ttVM_x86")) { ratingCheckEmulator++; } if (Build.FINGERPRINT.contains("generic") || Build.FINGERPRINT.contains("generic/sdk/generic") || Build.FINGERPRINT.contains("generic_x86/sdk_x86/generic_x86") || Build.FINGERPRINT.contains("Andy") || Build.FINGERPRINT.contains("ttVM_Hdragon") || Build.FINGERPRINT.contains("generic_x86_64") || Build.FINGERPRINT.contains("generic/google_sdk/generic") || Build.FINGERPRINT.contains("vbox86p") || Build.FINGERPRINT.contains("generic/vbox86p/vbox86p")) { ratingCheckEmulator++; } if (deepCheck) { try { String opengl = GLES20.glGetString(GLES20.GL_RENDERER); if (opengl != null) { if (opengl.contains("Bluestacks") || opengl.contains("Translator")) ratingCheckEmulator += 10; } } catch (Exception ignored) { } try { File sharedFolder = new File(Environment.getExternalStorageDirectory().toString() + File.separatorChar + "windows" + File.separatorChar + "BstSharedFolder"); if (sharedFolder.exists()) ratingCheckEmulator += 10; } catch (Exception ignored) { } } return ratingCheckEmulator > 3; }
From source file:fr.simon.marquis.secretcodes.util.ExportContentProvider.java
private void saveJsonFile(ArrayList<SecretCode> secretCodes) { try {// w ww . j a v a2s.co m JSONObject jsonObject = new JSONObject(); jsonObject.put(DEVICE_MANUFACTURER, Build.MANUFACTURER); jsonObject.put(DEVICE_MODEL, Build.MODEL); jsonObject.put(DEVICE_CODE_NAME, Build.DEVICE); jsonObject.put(DEVICE_LOCALE, Locale.getDefault().getDisplayName()); jsonObject.put(ANDROID_VERSION, String.valueOf(Build.VERSION.RELEASE)); JSONArray jsonArray = new JSONArray(); for (SecretCode secretCode : secretCodes) { jsonArray.put(secretCode.toJSON()); } jsonObject.put(SECRET_CODES, jsonArray); FileOutputStream openFileOutput = getContext().openFileOutput(JSON_FILE_NAME, Context.MODE_PRIVATE); openFileOutput.write(jsonObject.toString(4).getBytes()); openFileOutput.close(); } catch (FileNotFoundException e) { e.printStackTrace(); } catch (IOException e) { e.printStackTrace(); } catch (JSONException e) { e.printStackTrace(); } }
From source file:com.architjn.materialicons.ui.fragments.HomeFragment.java
@Override public boolean onOptionsItemSelected(MenuItem item) { // Handle action bar item clicks here. The action bar will // automatically handle clicks on the Home/Up button, so long // as you specify a parent activity in AndroidManifest.xml. int id = item.getItemId(); //noinspection SimplifiableIfStatement if (id == android.R.id.home) { drawer.openDrawer(Gravity.LEFT); }//from w ww. j a v a 2 s . co m if (id == R.id.action_sendemail) { StringBuilder emailBuilder = new StringBuilder(); Intent intent = new Intent(Intent.ACTION_VIEW, Uri.parse("mailto:" + getResources().getString(R.string.email_id))); intent.putExtra(Intent.EXTRA_SUBJECT, getResources().getString(R.string.email_subject)); emailBuilder.append("\n \n \nOS Version: ").append(System.getProperty("os.version")).append("(") .append(Build.VERSION.INCREMENTAL).append(")"); emailBuilder.append("\nOS API Level: ").append(Build.VERSION.SDK_INT); emailBuilder.append("\nDevice: ").append(Build.DEVICE); emailBuilder.append("\nManufacturer: ").append(Build.MANUFACTURER); emailBuilder.append("\nModel (and Product): ").append(Build.MODEL).append(" (").append(Build.PRODUCT) .append(")"); PackageInfo appInfo = null; try { appInfo = getActivity().getPackageManager().getPackageInfo(getActivity().getPackageName(), 0); } catch (PackageManager.NameNotFoundException e) { e.printStackTrace(); } assert appInfo != null; emailBuilder.append("\nApp Version Name: ").append(appInfo.versionName); emailBuilder.append("\nApp Version Code: ").append(appInfo.versionCode); intent.putExtra(Intent.EXTRA_TEXT, emailBuilder.toString()); startActivity(Intent.createChooser(intent, (getResources().getString(R.string.send_title)))); return true; } else if (id == R.id.action_share) { Intent sharingIntent = new Intent(Intent.ACTION_SEND); sharingIntent.setType("text/plain"); String shareBody = getResources().getString(R.string.share_one) + getResources().getString(R.string.developer_name) + getResources().getString(R.string.share_two) + MARKET_URL + getActivity().getPackageName(); sharingIntent.putExtra(Intent.EXTRA_TEXT, shareBody); startActivity(Intent.createChooser(sharingIntent, (getResources().getString(R.string.share_title)))); } else if (id == R.id.action_changelog) { showChangelog(); } return super.onOptionsItemSelected(item); }
From source file:org.kegbot.app.service.CheckinService.java
private void doCheckin() { Log.d(TAG, "Performing checkin: " + CHECKIN_URL); final long now = System.currentTimeMillis(); mPrefsHelper.setLastCheckinAttempt(now); final HttpClient client = new DefaultHttpClient(); final HttpPost request = new HttpPost(CHECKIN_URL); final HttpParams requestParams = new BasicHttpParams(); HttpProtocolParams.setUserAgent(requestParams, Utils.getUserAgent()); request.setParams(requestParams);//from w w w .ja va 2 s .c om try { List<NameValuePair> params = Lists.newArrayList(); params.add(new BasicNameValuePair("device_id", mDeviceId)); params.add(new BasicNameValuePair("android_version", Build.VERSION.SDK)); params.add(new BasicNameValuePair("android_device", Build.DEVICE)); params.add(new BasicNameValuePair("app_package", getPackageName())); params.add(new BasicNameValuePair("app_version", String.valueOf(mKegbotVersion))); params.add(new BasicNameValuePair("app_date", BuildInfo.BUILD_DATE_HUMAN)); params.add(new BasicNameValuePair("gcm_reg_id", mPrefsHelper.getGcmRegistrationId())); request.setEntity(new UrlEncodedFormEntity(params)); final HttpResponse response = client.execute(request); Log.d(TAG, "Checkin complete"); final String responseBody = EntityUtils.toString(response.getEntity()); final ObjectMapper mapper = new ObjectMapper(); final JsonNode rootNode = mapper.readValue(responseBody, JsonNode.class); if (response.getStatusLine().getStatusCode() == 200) { mPrefsHelper.setLastCheckinSuccess(now); mPrefsHelper.setIsRegistered(true); processLastCheckinResponse(rootNode); } } catch (IOException e) { Log.d(TAG, "Checkin failed: " + e); } }
From source file:com.keepsafe.switchboard.SwitchBoard.java
/** * Loads a new config for a user. This method allows you to pass your own unique user ID instead of using * the SwitchBoard internal user ID.// w w w .java 2 s .com * Don't call method direct for background threading reasons. * @param c ApplicationContext * @param uuid Custom unique user ID */ public static void loadConfig(Context c, String uuid) { try { //get uuid if (uuid == null) { DeviceUuidFactory df = new DeviceUuidFactory(c); uuid = df.getDeviceUuid().toString(); } String device = Build.DEVICE; String manufacturer = Build.MANUFACTURER; String lang = Locale.getDefault().getISO3Language(); String country = Locale.getDefault().getISO3Country(); String packageName = c.getPackageName(); String versionName = "none"; try { versionName = c.getPackageManager().getPackageInfo(c.getPackageName(), 0).versionName; } catch (NameNotFoundException e) { e.printStackTrace(); } //load config, includes all experiments String serverUrl = Preferences.getDynamicConfigServerUrl(c); if (serverUrl != null) { String params = "uuid=" + uuid + "&device=" + device + "&lang=" + lang + "&country=" + country + "&manufacturer=" + manufacturer + "&appId=" + packageName + "&version=" + versionName; if (DEBUG) Log.d(TAG, "Read from server URL: " + serverUrl + params); String serverConfig = readFromUrlGET(serverUrl, params); if (DEBUG) Log.d(TAG, serverConfig); //store experiments in shared prefs (one variable) if (serverConfig != null) Preferences.setDynamicConfigJson(c, serverConfig); } } catch (NullPointerException e) { e.printStackTrace(); } }
From source file:edu.tjhsst.ion.gcmFrame.MainActivity.java
@Override protected void onCreate(Bundle savedInstanceState) { super.onCreate(savedInstanceState); this.setContentView(R.layout.activity_main); if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.LOLLIPOP) { Window window = getWindow(); window.addFlags(WindowManager.LayoutParams.FLAG_DRAWS_SYSTEM_BAR_BACKGROUNDS); window.setStatusBarColor(getResources().getColor(R.color.navbar_color)); }//from w w w.j ava 2s. co m // requestWindowFeature(Window.FEATURE_NO_TITLE); mRegistrationBroadcastReceiver = new BroadcastReceiver() { @Override public void onReceive(Context context, Intent intent) { SharedPreferences sharedPreferences = PreferenceManager.getDefaultSharedPreferences(context); boolean sentToken = sharedPreferences.getBoolean(QuickstartPreferences.SENT_TOKEN_TO_SERVER, false); if (sentToken) { Log.i(TAG, "Google token sent"); } else { Toast.makeText(getApplicationContext(), getString(R.string.token_error_message), Toast.LENGTH_LONG).show(); } } }; if (checkPlayServices()) { // Start IntentService to register this application with GCM. Intent intent = new Intent(this, RegistrationIntentService.class); startService(intent); } ConnectivityManager connectivityManager = (ConnectivityManager) getSystemService( Context.CONNECTIVITY_SERVICE); if (connectivityManager != null) { NetworkInfo ni = connectivityManager.getActiveNetworkInfo(); if (ni != null) { NetworkInfo.State state = ni.getState(); if (state == null || state != NetworkInfo.State.CONNECTED) { // record the fact that there is no connection isConnected = false; } } } SharedPreferences sharedPreferences = PreferenceManager .getDefaultSharedPreferences(getApplicationContext()); boolean sentToken = sharedPreferences.getBoolean(QuickstartPreferences.ION_SETUP, false); webView = (WebView) findViewById(R.id.webview); webView.setInitialScale(1); webView.getSettings().setJavaScriptEnabled(true); webView.getSettings().setLoadWithOverviewMode(true); webView.getSettings().setUseWideViewPort(true); webView.setScrollBarStyle(WebView.SCROLLBARS_OUTSIDE_OVERLAY); webView.setScrollbarFadingEnabled(false); if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.KITKAT) { WebView.setWebContentsDebuggingEnabled(true); } StringBuilder uaString = new StringBuilder(webView.getSettings().getUserAgentString()); uaString.append(" - IonAndroid: gcmFrame ("); if (sentToken) { uaString.append("appRegistered:True"); } else { uaString.append("appRegistered:False"); } uaString.append(" osVersion:").append(System.getProperty("os.version")); uaString.append(" apiLevel:").append(android.os.Build.VERSION.SDK_INT); uaString.append(" Device:").append(android.os.Build.DEVICE); uaString.append(" Model:").append(android.os.Build.MODEL); uaString.append(" Product:").append(android.os.Build.PRODUCT); uaString.append(")"); webView.getSettings().setUserAgentString(uaString.toString()); webView.setNetworkAvailable(isConnected); webView.addJavascriptInterface(new WebAppInterface(this), "IonAndroidInterface"); webView.loadUrl(MainActivity.ION_HOST); webView.setWebViewClient(new WebViewClient() { @Override public boolean shouldOverrideUrlLoading(WebView view, String url) { Log.d(TAG, "Loading " + url); if (!isConnected) { String html = getHtml("offline.html"); html = html.replaceAll("\\[url\\]", url); view.loadData(html, "text/html", "utf-8"); return true; } else if (url.contains(ION_HOST)) { // keep in WebView webView.loadUrl(url); return true; } else { Intent intent = new Intent(Intent.ACTION_VIEW); intent.setData(Uri.parse(url)); startActivity(intent); return true; } } @Override public void onReceivedError(WebView view, int errorCode, String description, String failingUrl) { // if (errorCode == ERROR_TIMEOUT) view.stopLoading(); // may not be needed String html = getHtml("timeout.html"); html = html.replaceAll("\\[url\\]", failingUrl); html = html.replaceAll("\\[desc\\]", description); view.loadData(html, "text/html", "utf-8"); } }); }
From source file:com.framgia.android.emulator.EmulatorDetector.java
private boolean checkBasic() { boolean result = Build.FINGERPRINT.startsWith("generic") || Build.MODEL.contains("google_sdk") || Build.MODEL.toLowerCase().contains("droid4x") || Build.MODEL.contains("Emulator") || Build.MODEL.contains("Android SDK built for x86") || Build.MANUFACTURER.contains("Genymotion") || Build.HARDWARE.equals("goldfish") || Build.HARDWARE.equals("vbox86") || Build.PRODUCT.equals("sdk") || Build.PRODUCT.equals("google_sdk") || Build.PRODUCT.equals("sdk_x86") || Build.PRODUCT.equals("vbox86p") || Build.BOARD.toLowerCase().contains("nox") || Build.BOOTLOADER.toLowerCase().contains("nox") || Build.HARDWARE.toLowerCase().contains("nox") || Build.PRODUCT.toLowerCase().contains("nox") || Build.SERIAL.toLowerCase().contains("nox"); if (result)/* w ww . j av a 2 s . c o m*/ return true; result |= Build.BRAND.startsWith("generic") && Build.DEVICE.startsWith("generic"); if (result) return true; result |= "google_sdk".equals(Build.PRODUCT); return result; }