15

How to get the device model name ? I have a Yuphoria 5010 which displays YU5010 in device Model Number, I want to fetch the full name of the device? I want the fetch the exact string given below:

Yuphoria 5010 6.0 Marshmallow

Jim Raynor
  • 295
  • 1
  • 2
  • 9

4 Answers4

59

It was really simple, just call:

String model = Build.MODEL;

Update: This code will print the exact string you requested:

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

Prints:

Samsung Note 4 6.0 MARSHMALLOW

LGE LG-D410 4.4.2 KITKAT

Hisham Muneer
  • 8,558
  • 10
  • 54
  • 79
6

On many popular devices the market name of the device is not available. For example, on the Samsung Galaxy S6 the value of Build.MODEL could be "SM-G920F", "SM-G920I", or "SM-G920W8". So for getting full device name you can use a library which is available on github . Link of AndroidDeviceLibrary is here https://github.com/shubhamsharmacs/AndroidDeviceNames

Now how to use these library :- put these in your build.gradle file

compile 'com.jaredrummler:android-device-names:1.0.9'

Now these operations are :

Get the name of the current device:

String deviceName = DeviceName.getDeviceName();

The above code will get the correct device name for the top 600 Android devices. If the device is unrecognized, then Build.MODEL is returned. This can be executed from the UI thread.

Get the name of a device using the device's codename:

// Retruns "Moto X Style"
DeviceName.getDeviceName("clark", "Unknown device");

Get information about the device:

DeviceName.with(context).request(new DeviceName.Callback() {

  @Override public void onFinished(DeviceName.DeviceInfo info, Exception error) {
    String manufacturer = info.manufacturer;  // "Samsung"
    String name = info.marketName;            // "Galaxy S7 Edge"
    String model = info.model;                // "SAMSUNG-SM-G935A"
    String codename = info.codename;          // "hero2lte"
    String deviceName = info.getName();       // "Galaxy S7 Edge"
    // FYI: We are on the UI thread.
  }
});

The above code loads JSON from a generated list of device names based on Google's maintained list. It will be up-to-date with Google's supported device list so that you will get the correct name for new or unknown devices. This supports over 10,000 devices.

This will only make a network call once. The value is saved to SharedPreferences for future calls.

Shubham Sharma
  • 2,763
  • 5
  • 31
  • 46
  • 1
    it is also right answer @jim – Shubham Sharma Jul 02 '16 at 07:45
  • Its a good solution, but the library has not been updated since 2016. So new devices are not present. It needs to be updated at least once a year to have real value. – dazed Nov 22 '18 at 21:20
  • Don't be fooled - this library has been updated. The link here is to a fork of the real library. The real library (https://github.com/jaredrummler/AndroidDeviceNames) was updated in June! – Troy Stopera Aug 03 '19 at 16:43
6

You can get the device details by using the below code.

String s="Debug-infos:\n";
s += "OS Version: " + System.getProperty("os.version") + "(" + android.os.Build.VERSION.INCREMENTAL + ")\n";
s += "OS API Level: " + android.os.Build.VERSION.RELEASE + "(" + android.os.Build.VERSION.SDK_INT + ")\n";
s += "Device: " + android.os.Build.DEVICE + "\n";
s += "Model (and Product): " + android.os.Build.MODEL + " ("+ android.os.Build.PRODUCT + ")\n";
Kusalananda
  • 14,885
  • 3
  • 41
  • 52
4

USe this code for get device Model

import android.os.Build;

String deviceModel = Build.MODEL;

if you want get this info in android 6.0 Marshmellow so before this get info give the run time permission

Manifest.permission.READ_PHONE_STATE
Nitesh Pareek
  • 362
  • 2
  • 10