Example usage for android.os Build MODEL

List of usage examples for android.os Build MODEL

Introduction

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

Prototype

String MODEL

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

Click Source Link

Document

The end-user-visible name for the end product.

Usage

From source file:com.example.david.wheretogo_test1.PickerActivity.java

@Override
protected void onStart() {
    super.onStart();
    if (FRIEND_PICKER.equals(getIntent().getData())) {
        try {// ww  w  .j  a  v a2  s .c o m
            friendPickerFragment.loadData(false);
        } catch (Exception ex) {
            onError(ex);
        }
    } else if (PLACE_PICKER.equals(getIntent().getData())) {
        try {
            Location location = null;
            Criteria criteria = new Criteria();
            LocationManager locationManager = (LocationManager) getSystemService(Context.LOCATION_SERVICE);
            String bestProvider = locationManager.getBestProvider(criteria, false);
            if (bestProvider != null) {
                location = locationManager.getLastKnownLocation(bestProvider);
                if (locationManager.isProviderEnabled(bestProvider) && locationListener == null) {
                    locationListener = new LocationListener() {
                        @Override
                        public void onLocationChanged(Location location) {
                            boolean updateLocation = true;
                            Location prevLocation = placePickerFragment.getLocation();
                            if (prevLocation != null) {
                                updateLocation = location.distanceTo(prevLocation) >= LOCATION_CHANGE_THRESHOLD;
                            }
                            if (updateLocation) {
                                placePickerFragment.setLocation(location);
                                placePickerFragment.loadData(true);
                            }
                        }

                        @Override
                        public void onStatusChanged(String s, int i, Bundle bundle) {
                        }

                        @Override
                        public void onProviderEnabled(String s) {
                        }

                        @Override
                        public void onProviderDisabled(String s) {
                        }
                    };
                    locationManager.requestLocationUpdates(bestProvider, 1, LOCATION_CHANGE_THRESHOLD,
                            locationListener, Looper.getMainLooper());
                }
            }
            if (location == null) {
                String model = Build.MODEL;
                if (model.equals("sdk") || model.equals("google_sdk") || model.contains("x86")) {
                    // this may be the emulator, pretend we're in an exotic place
                    location = SAN_FRANCISCO_LOCATION;
                }
            }
            if (location != null) {
                placePickerFragment.setLocation(location);
                placePickerFragment.setRadiusInMeters(SEARCH_RADIUS_METERS);
                placePickerFragment.setSearchText(SEARCH_TEXT);
                placePickerFragment.setResultsLimit(SEARCH_RESULT_LIMIT);
                placePickerFragment.loadData(false);
            } else {
                onError(getResources().getString(R.string.no_location_error), true);
            }
        } catch (Exception ex) {
            onError(ex);
        }
    }
}

From source file:it.evilsocket.dsploit.core.System.java

public static void init(Context context) throws Exception {
    mContext = context;/*from www  .j  a  va 2s  . c  o m*/
    try {
        mStoragePath = getSettings().getString("PREF_SAVE_PATH",
                Environment.getExternalStorageDirectory().toString());
        mSessionName = "dsploit-session-" + java.lang.System.currentTimeMillis();
        mUpdateManager = new UpdateManager(mContext);
        mPlugins = new ArrayList<Plugin>();
        mTargets = new Vector<Target>();
        mOpenPorts = new SparseIntArray(3);

        // if we are here, network initialization didn't throw any error, lock wifi
        WifiManager wifiManager = (WifiManager) mContext.getSystemService(Context.WIFI_SERVICE);

        if (mWifiLock == null)
            mWifiLock = wifiManager.createWifiLock(WifiManager.WIFI_MODE_FULL, "wifiLock");

        if (mWifiLock.isHeld() == false)
            mWifiLock.acquire();

        // wake lock if enabled
        if (getSettings().getBoolean("PREF_WAKE_LOCK", true) == true) {
            PowerManager powerManager = (PowerManager) mContext.getSystemService(Context.POWER_SERVICE);

            if (mWakeLock == null)
                mWakeLock = powerManager.newWakeLock(PowerManager.FULL_WAKE_LOCK, "wakeLock");

            if (mWakeLock.isHeld() == false)
                mWakeLock.acquire();
        }

        // set ports
        try {
            HTTP_PROXY_PORT = Integer.parseInt(getSettings().getString("PREF_HTTP_PROXY_PORT", "8080"));
            HTTP_SERVER_PORT = Integer.parseInt(getSettings().getString("PREF_HTTP_SERVER_PORT", "8081"));
            HTTPS_REDIR_PORT = Integer.parseInt(getSettings().getString("PREF_HTTPS_REDIRECTOR_PORT", "8082"));
        } catch (NumberFormatException e) {
            HTTP_PROXY_PORT = 8080;
            HTTP_SERVER_PORT = 8081;
            HTTPS_REDIR_PORT = 8082;
        }

        mNmap = new NMap(mContext);
        mArpSpoof = new ArpSpoof(mContext);
        mEttercap = new Ettercap(mContext);
        mIptables = new IPTables();
        mHydra = new Hydra(mContext);
        mTcpdump = new TcpDump(mContext);

        // initialize network data at the end
        mNetwork = new Network(mContext);

        Target network = new Target(mNetwork),
                gateway = new Target(mNetwork.getGatewayAddress(), mNetwork.getGatewayHardware()),
                device = new Target(mNetwork.getLocalAddress(), mNetwork.getLocalHardware());

        gateway.setAlias(mNetwork.getSSID());
        device.setAlias(android.os.Build.MODEL);

        mTargets.add(network);
        mTargets.add(gateway);
        mTargets.add(device);

        mInitialized = true;
    } catch (Exception e) {
        errorLogging(TAG, e);

        throw e;
    }
}

From source file:gwind.windalarm.RegistrationIntentService.java

/**
 * Persist registration to third-party servers.
 *
 * Modify this method to associate the user's GCM registration token with any server-side account
 * maintained by your application./* w ww  . ja  v  a2s  . c om*/
 *
 * @param token The new token.
 */
private void sendRegistrationToServer(final String personId, final String personName, final String personEmail,
        String personPhoto, String authCode) {
    // Add custom implementation, as needed.
    //ServerUtilities.register(token, serverURL);
    String model = Build.MODEL;

    new registertask(SplashActivity.getInstance(), new AsyncRegisterResponse() {

        @Override
        public void processFinish(String jsonStr, boolean error, String errorMessage) {

            if (error)
                CommonUtilities.sendMessageToMainActivity(SplashActivity.getContext(), "errore registrazione",
                        errorMessage);

            try {
                JSONObject json = new JSONObject(jsonStr);
                int deviceId = -1;
                int userId = -1;
                if (json.has("deviceid")) {
                    deviceId = json.getInt("deviceid");
                    //long old_deviceId = AlarmPreferences.getDeviceId(SplashActivity.getContext());
                    AlarmPreferences.setDeviceId(SplashActivity.getContext(), deviceId);
                }
                if (json.has("userid")) {
                    userId = json.getInt("userid");
                    //AlarmPreferences.setUserId(SplashActivity.getContext(), userId);
                }
                /*AlarmPreferences.setPersonId(SplashActivity.getContext(), personId);
                if (personEmail != null)
                AlarmPreferences.setEmail(SplashActivity.getContext(), personEmail);
                if (personName != null)
                AlarmPreferences.setUserName(SplashActivity.getContext(), personName);*/
                CommonUtilities.sendMessageToMainActivity(SplashActivity.getContext(), "title",
                        "Registrazione utente completata: deviceid=" + deviceId + "userId=" + userId);
            } catch (JSONException e) {
                e.printStackTrace();
                CommonUtilities.sendMessageToMainActivity(SplashActivity.getContext(), "title",
                        "impossibile registrare device");
            }
        }
    }, registertask.POST_REGISTERUSER).execute(AlarmPreferences.getRegId(this), model, personId, personName,
            personEmail, personPhoto, authCode);

}

From source file:com.test.hwautotest.emmagee.service.EmmageeService.java

/**
 * write the test result to csv format report.
 *///from   w ww  .  j  a  v  a2s .  co m
private void createResultCsv() {
    Calendar cal = Calendar.getInstance();
    SimpleDateFormat formatter = new SimpleDateFormat("yyyyMMddHHmmss");
    String mDateTime;
    if ((Build.MODEL.equals("sdk")) || (Build.MODEL.equals("google_sdk")))
        mDateTime = formatter.format(cal.getTime().getTime() + 8 * 60 * 60 * 1000);
    else
        mDateTime = formatter.format(cal.getTime().getTime());

    if (android.os.Environment.getExternalStorageState().equals(android.os.Environment.MEDIA_MOUNTED)) {
        resultFilePath = android.os.Environment.getExternalStorageDirectory() + File.separator + "TestReport"
                + File.separator + "?__" + processName + "_" + mDateTime + ".csv";
    } else {
        resultFilePath = getBaseContext().getFilesDir().getPath() + File.separator + "TestReport"
                + File.separator + "?__" + processName + "_" + mDateTime + ".csv";
    }
    readyResultFile();
    //      try {
    //         File resultFile = new File(resultFilePath);
    //         //
    //         if(!resultFile.getParentFile().exists()){
    //            resultFile.getParentFile().mkdir();
    //         }
    //            
    ////         Log.e(LOG_TAG, "resultFile.createNewFile()"+resultFile.createNewFile());
    //         readyResultFile();
    //         out = new FileOutputStream(resultFile,true);
    //         osw = new OutputStreamWriter(out, "GBK");
    //         bw = new BufferedWriter(osw);
    //         long totalMemorySize = memoryInfo.getTotalMemory();
    //         String totalMemory = fomart.format((double) totalMemorySize / 1024);
    //         bw.write("CPU\r\n" + "??," + packageName + "\r\n"
    //               + "??: ," + processName + "\r\n" + "PID: ," + pid
    //               + "\r\n" + "?(MB)," + totalMemory + "MB\r\n"
    //               + "CPU?," + cpuInfo.getCpuName() + "\r\n"
    //               + "android," + memoryInfo.getSDKVersion() + "\r\n"
    //               + "?," + memoryInfo.getPhoneType() + "\r\n" + "UID,"
    //               + uid + "\r\n");
    //         bw.write("" + "," + "?PSS(MB)" + "," + "?(%)" + ","
    //               + " (MB)" + "," + "?CPU(%)" + "," + "CPU(%)"
    //               + "," + "??(KB)" + "\r\n");
    //      } catch (IOException e) {
    //         Log.e(LOG_TAG, "resultFile?"+e.getMessage());
    //      }
}

From source file:net.olejon.spotcommander.MainActivity.java

@Override
protected void onCreate(Bundle savedInstanceState) {
    super.onCreate(savedInstanceState);

    // Settings/*www . ja  v  a2s. co  m*/
    PreferenceManager.setDefaultValues(mContext, R.xml.settings, false);

    // Allow landscape?
    if (!mTools.allowLandscape())
        setRequestedOrientation(ActivityInfo.SCREEN_ORIENTATION_PORTRAIT);

    // Google API client
    mGoogleApiClient = new GoogleApiClient.Builder(mContext).addApiIfAvailable(Wearable.API).build();

    // Database
    mDatabase = new MainSQLiteHelper(mContext).getWritableDatabase();

    // Layout
    setContentView(R.layout.activity_main);

    // Toolbar
    final Toolbar toolbar = (Toolbar) findViewById(R.id.main_toolbar);
    toolbar.setTitle(getString(R.string.main_title));

    setSupportActionBar(toolbar);

    // Listview
    mListView = (ListView) findViewById(R.id.main_list);

    final View listViewHeader = getLayoutInflater().inflate(R.layout.activity_main_subheader, mListView, false);
    mListView.addHeaderView(listViewHeader, null, false);

    final View listViewEmpty = findViewById(R.id.main_empty);
    mListView.setEmptyView(listViewEmpty);

    mListView.setLongClickable(true);

    mListView.setOnItemClickListener(new OnItemClickListener() {
        @Override
        public void onItemClick(AdapterView<?> parent, View view, int position, long id) {
            openComputer(id);
        }
    });

    mListView.setOnItemLongClickListener(new OnItemLongClickListener() {
        @Override
        public boolean onItemLongClick(AdapterView<?> adapterView, View view, int i, final long id) {
            new MaterialDialog.Builder(mContext).title(R.string.main_remove_computer_dialog_title)
                    .content(getString(R.string.main_remove_computer_dialog_message))
                    .positiveText(R.string.main_remove_computer_dialog_positive_button)
                    .negativeText(R.string.main_remove_computer_dialog_negative_button)
                    .onPositive(new MaterialDialog.SingleButtonCallback() {
                        @Override
                        public void onClick(@NonNull MaterialDialog materialDialog,
                                @NonNull DialogAction dialogAction) {
                            removeComputer(id);

                            listComputers();
                        }
                    }).contentColorRes(R.color.black).negativeColorRes(R.color.black).show();

            return true;
        }
    });

    // Floating action button
    mFloatingActionButton = (FloatingActionButton) findViewById(R.id.main_fab);

    mFloatingActionButton.setOnClickListener(new View.OnClickListener() {
        @Override
        public void onClick(View view) {
            Intent intent = new Intent(mContext, AddComputerActivity.class);
            startActivity(intent);
        }
    });

    // Donate button
    final Button button = (Button) findViewById(R.id.main_make_donation_button);

    button.setOnClickListener(new View.OnClickListener() {
        @Override
        public void onClick(View view) {
            Intent intent = new Intent(mContext, DonateActivity.class);
            startActivity(intent);
        }
    });

    // Information dialog
    if (Build.VERSION.SDK_INT < Build.VERSION_CODES.KITKAT) {
        if (!mTools.getSharedPreferencesBoolean("HIDE_INFORMATION_DIALOG_75")) {
            new MaterialDialog.Builder(mContext).title(R.string.main_information_dialog_title)
                    .content(getString(R.string.main_information_dialog_message))
                    .positiveText(R.string.main_information_dialog_positive_button)
                    .onPositive(new MaterialDialog.SingleButtonCallback() {
                        @Override
                        public void onClick(@NonNull MaterialDialog materialDialog,
                                @NonNull DialogAction dialogAction) {
                            mTools.setSharedPreferencesBoolean("HIDE_INFORMATION_DIALOG_75", true);
                        }
                    }).contentColorRes(R.color.black).show();
        }
    }

    // Message dialog
    String version = mTools.getProjectVersionName();
    String device = "";

    try {
        device = (Build.MANUFACTURER == null || Build.MODEL == null || Build.VERSION.SDK_INT < 1) ? ""
                : URLEncoder.encode(Build.MANUFACTURER + " " + Build.MODEL + " " + Build.VERSION.SDK_INT,
                        "utf-8");
    } catch (Exception e) {
        Log.e("MainActivity", Log.getStackTraceString(e));
    }

    final Cache cache = new DiskBasedCache(getCacheDir(), 0);

    final Network network = new BasicNetwork(new HurlStack());

    final RequestQueue requestQueue = new RequestQueue(cache, network);

    requestQueue.start();

    final JsonObjectRequest jsonObjectRequest = new JsonObjectRequest(Request.Method.GET,
            getString(R.string.project_website) + "api/1/android/message/?version_name=" + version + "&device="
                    + device,
            null, new Response.Listener<JSONObject>() {
                @Override
                public void onResponse(JSONObject response) {
                    requestQueue.stop();

                    try {
                        final long id = response.getLong("id");
                        final String title = response.getString("title");
                        final String message = response.getString("message");

                        final long lastId = mTools.getSharedPreferencesLong("LAST_MESSAGE_ID");

                        if (lastId == 0) {
                            mTools.setSharedPreferencesLong("LAST_MESSAGE_ID", id);
                        } else if (id != lastId) {
                            new MaterialDialog.Builder(mContext).title(title).content(message)
                                    .positiveText(R.string.main_message_dialog_positive_button)
                                    .onPositive(new MaterialDialog.SingleButtonCallback() {
                                        @Override
                                        public void onClick(@NonNull MaterialDialog materialDialog,
                                                @NonNull DialogAction dialogAction) {
                                            mTools.setSharedPreferencesLong("LAST_MESSAGE_ID", id);
                                        }
                                    }).contentColorRes(R.color.black).show();
                        }
                    } catch (Exception e) {
                        Log.e("MainActivity", Log.getStackTraceString(e));
                    }
                }
            }, new Response.ErrorListener() {
                @Override
                public void onErrorResponse(VolleyError error) {
                    requestQueue.stop();

                    Log.e("MainActivity", error.toString());
                }
            });

    jsonObjectRequest.setRetryPolicy(new DefaultRetryPolicy(10000, DefaultRetryPolicy.DEFAULT_MAX_RETRIES,
            DefaultRetryPolicy.DEFAULT_BACKOFF_MULT));

    requestQueue.add(jsonObjectRequest);

    // Google analytics
    final GoogleAnalytics googleAnalytics = GoogleAnalytics.getInstance(mContext);
    final Tracker tracker = googleAnalytics.newTracker(R.xml.app_tracker);
    tracker.send(new HitBuilders.ScreenViewBuilder().build());
}

From source file:org.centum.android.MainActivity.java

/**
 * Report uncaught exceptions (crashes) to Analytics
 *///from  ww  w.j  a v  a 2 s.co  m
private void setupUncaughtExceptionHandler() {
    ExceptionReporter myHandler = new ExceptionReporter(EasyTracker.getInstance(this),
            GAServiceManager.getInstance(), Thread.getDefaultUncaughtExceptionHandler(), this);

    StandardExceptionParser exceptionParser = new StandardExceptionParser(getApplicationContext(), null) {
        @Override
        public String getDescription(String threadName, Throwable t) {
            return "{" + threadName + "} " + "{" + Build.MODEL + "} " + "{" + Build.VERSION.SDK_INT + "} "
                    + Log.getStackTraceString(t);
        }
    };

    myHandler.setExceptionParser(exceptionParser);
    Thread.setDefaultUncaughtExceptionHandler(myHandler);
}

From source file:com.vinexs.tool.Utility.java

public static String getUserDeviceModel() {
    String manufacturer = Build.MANUFACTURER;
    String model = Build.MODEL;
    if (model.startsWith(manufacturer)) {
        return model;
    }/*  ww  w.ja  v  a  2s  . co m*/
    return manufacturer + " " + model;
}

From source file:com.jins_meme.bridge.HueController.java

HueController(Context context, FragmentManager fragmentManager) {
    handler = new Handler();

    sharedPreferences = context.getSharedPreferences(HUE_SHARED_PREFERENCES_STORE, 0);
    sharedPreferencesEditor = sharedPreferences.edit();

    this.fragmentManager = fragmentManager;

    alert = new AlertDialog.Builder(context);

    hueSDK = PHHueSDK.create();// w  ww.  java2 s  . com

    hueSDK.setAppName("JINS MEME BRIDGE");
    hueSDK.setDeviceName(Build.MODEL);

    hueSDK.getNotificationManager().registerSDKListener(this);

    if (getLastConnectedIp() != null && !getLastConnectedIp().equals("")) {
        Log.d("HUE", "connect... " + getLastConnectedIp() + " / " + getUsername());

        PHAccessPoint accessPoint = new PHAccessPoint();
        accessPoint.setIpAddress(getLastConnectedIp());
        accessPoint.setUsername(getUsername());

        if (!hueSDK.isAccessPointConnected(accessPoint)) {
            hueSDK.connect(accessPoint);
        } else {
            PHBridge bridge = hueSDK.getSelectedBridge();
            allLights = bridge.getResourceCache().getAllLights();

            for (PHLight light : allLights) {
                PHLightState lightState = light.getLastKnownLightState();

                Log.d("DEBUG",
                        "HUE:: id = " + light.getIdentifier() + " " + light.getModelNumber() + " "
                                + light.getUniqueId() + " " + lightState.getBrightness() + " "
                                + lightState.getSaturation());
                Log.d("DEBUG",
                        "HUE:: type = " + light.getLightType().name() + " " + light.getLightType().ordinal());
            }
        }
    }
}

From source file:com.sitewhere.android.example.MainActivity.java

private Map<String, String> buildRegistrationMetadata() {
    Map<String, String> metadata = new HashMap<>();

    WifiManager wm = (WifiManager) getApplicationContext().getSystemService(WIFI_SERVICE);
    String ip = Formatter.formatIpAddress(wm.getConnectionInfo().getIpAddress());

    String reqString = Build.MANUFACTURER + " " + Build.MODEL + " " + Build.VERSION.RELEASE + " "
            + Build.VERSION_CODES.class.getFields()[android.os.Build.VERSION.SDK_INT].getName();

    metadata.put("ipaddress", ip);
    metadata.put("android.os.version", Build.VERSION.BASE_OS);
    metadata.put("android.os.description", reqString);

    return metadata;
}

From source file:jahirfiquitiva.iconshowcase.utilities.Utils.java

public static void sendEmailWithDeviceInfo(Context context) {
    StringBuilder emailBuilder = new StringBuilder();
    Intent intent = new Intent(Intent.ACTION_VIEW,
            Uri.parse("mailto:" + context.getResources().getString(R.string.email_id)));
    intent.putExtra(Intent.EXTRA_SUBJECT, context.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;//from  w w  w  .j  a va  2 s.  c  om
    try {
        appInfo = context.getPackageManager().getPackageInfo(context.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());
    context.startActivity(
            Intent.createChooser(intent, (context.getResources().getString(R.string.send_title))));
}