MaxstARSDK
|
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) |
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.
|
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.
context | the application 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.
context | the application context. |
codename | the codename of the device |
|
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.
context | the application context. |
codename | the codename of the device |
model | the model of the device |
|
static |
Get the consumer friendly name of the device.
|
static |
Get the consumer friendly name of a device.
codename | the value of the system property "ro.product.device" (Build#DEVICE). |
model | the value of the system property "ro.product.model" (Build#MODEL). |
fallback | the fallback name if the device is unknown. Usually the value of the system property "ro.product.model" (Build#MODEL) |