MaxstARSDK
com.maxst.ar.DeviceName Class Reference
Collaboration diagram for com.maxst.ar.DeviceName:
Collaboration graph

Classes

class  DeviceInfo
 

Static Public Member Functions

static String getDeviceName ()
 
static String getDeviceName (String codename, String model, String fallback)
 
static DeviceInfo getDeviceInfo (Context context)
 
static DeviceInfo getDeviceInfo (Context context, String codename)
 
static DeviceInfo getDeviceInfo (Context context, String codename, String model)
 

Detailed Description

Get the consumer friendly name of an Android device.

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", "SM-G920W8", etc.

See the usages below to get the consumer friends name of a device:

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.

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 S6 Edge"
    String model = info.model;                // "SM-G925I"
    String codename = info.codename;          // "zerolte"
    String deviceName = info.getName();       // "Galaxy S6 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.

Member Function Documentation

◆ getDeviceInfo() [1/3]

static DeviceInfo com.maxst.ar.DeviceName.getDeviceInfo ( Context  context)
static

Get the DeviceInfo for the current device. Do not run on the UI thread, as this may download JSON to retrieve the DeviceInfo. JSON is only downloaded once and then stored to SharedPreferences.

Parameters
contextthe application context.
Returns
DeviceInfo for the current device.
Here is the caller graph for this function:

◆ getDeviceInfo() [2/3]

static DeviceInfo com.maxst.ar.DeviceName.getDeviceInfo ( Context  context,
String  codename 
)
static

Get the DeviceInfo for the current device. Do not run on the UI thread, as this may download JSON to retrieve the DeviceInfo. JSON is only downloaded once and then stored to SharedPreferences.

Parameters
contextthe application context.
codenamethe codename of the device
Returns
DeviceInfo for the current device.
Here is the call graph for this function:

◆ getDeviceInfo() [3/3]

static DeviceInfo com.maxst.ar.DeviceName.getDeviceInfo ( Context  context,
String  codename,
String  model 
)
static

Get the DeviceInfo for the current device. Do not run on the UI thread, as this may download JSON to retrieve the DeviceInfo. JSON is only downloaded once and then stored to SharedPreferences.

Parameters
contextthe application context.
codenamethe codename of the device
modelthe model of the device
Returns
DeviceInfo for the current device.
Here is the call graph for this function:

◆ getDeviceName() [1/2]

static String com.maxst.ar.DeviceName.getDeviceName ( )
static

Get the consumer friendly name of the device.

Returns
the market name of the current device.
Here is the caller graph for this function:

◆ getDeviceName() [2/2]

static String com.maxst.ar.DeviceName.getDeviceName ( String  codename,
String  model,
String  fallback 
)
static

Get the consumer friendly name of a device.

Parameters
codenamethe value of the system property "ro.product.device" (Build#DEVICE).
modelthe value of the system property "ro.product.model" (Build#MODEL).
fallbackthe fallback name if the device is unknown. Usually the value of the system property "ro.product.model" (Build#MODEL)
Returns
the market name of a device or
fallback
if the device is unknown.

The documentation for this class was generated from the following file: