0

I have a question about Android Model number under android.os.Build. My requirement is, I need a unique number to identify the model of the particular device.The model number will send to my server with the help of a REST API. Then the server will provide the detailed model information of the particular device. So That I am trying to access the model number from android.os.Build. The developer site saying the definition of the same is "The end-user-visible name for the end product".

So my question is, Is the model number is unique in all over the world? Or it changes based on different country? Or it changes based on the store (Play store, Amazon store etc.)?.

Nithinjith
  • 1,775
  • 18
  • 40
  • What about IMEI number ? Is it better than model number ? – Sree Mar 02 '16 at 08:47
  • Yes, I suggest the same. But the problem is, I need to Identify the model. Not that particular device. Is it possible to identify the model using IMEI? – Nithinjith Mar 02 '16 at 08:49
  • 1
    there is a third party link https://imeidata.net/, i do't know about any api service available for this – Sree Mar 02 '16 at 08:52

2 Answers2

2

Yes model numbers are same for the device all over the world.

Use follong code to get the modelNumber:

 public String getDeviceName() {
    String manufacturer = Build.MANUFACTURER;
    String model = Build.MODEL;
    if (model.startsWith(manufacturer)) {
        return capitalize(model);
    } else {
        return capitalize(manufacturer) + " " + model;
    }
}


private String capitalize(String s) {
    if (s == null || s.length() == 0) {
        return "";
    }
    char first = s.charAt(0);
    if (Character.isUpperCase(first)) {
        return s;
    } else {
        return Character.toUpperCase(first) + s.substring(1);
    }
} 

This will give you the unique model number.

For the reference please refer the post

Community
  • 1
  • 1
1

In order to uniquely identify a device you can use the Secure class in which is part of the Android's Settings package. which returns the Android ID as n unique 64-bit hex string. This way:

import android.provider.Settings.Secure;
private String android_id = Secure.getString(getContext().getContentResolver(),
                                                        Secure.ANDROID_ID); 

However, this is non to be null sometimes. An all perfect complete solution to uniquely identify a device is yet to come up. There are various factors to be considered while acquiring the unique id of a device. Also see this Answer

Community
  • 1
  • 1
Shafqat Kamal
  • 439
  • 4
  • 12