3

I get device names by the command "adb deivces" in command line. Now I want get name in my android device.

  String serial = null;     
    try {         
        Class<?> c = Class.forName("android.os.SystemProperties");    
        Method get = c.getMethod("get", String.class);   
        serial = (String) get.invoke(c, "ro.serialno");  
        System.out.println(serial);
        } 
    catch (Exception ignored) {  

    }

those works fine in my android phone.But my acer a500 tablet gets the real serial number. This is not correspond with the name I get from the adb command.

I surpose the ddms gets the devices name by another method. But i dont know.

wiseideal
  • 65
  • 1
  • 1
  • 6
  • http://stackoverflow.com/questions/2785485/is-there-a-unique-android-device-id – Nikunj Patel Aug 31 '11 at 07:43
  • The name you get from ADB is automatically generated and not taken from the actual device, based on this: http://developer.android.com/guide/developing/tools/adb.html#devicestatus – Matthew Read Jan 31 '12 at 17:28

4 Answers4

7

getting-android-device-name i do hope this link may help you.

TextView tv1 = (TextView) findViewById(R.id.tv1);

String str = android.os.Build.MODEL;

tv1.setText(str);

Kalu Khan Luhar
  • 1,044
  • 1
  • 22
  • 35
6

android.os.Build contains device info. You're probably interested in Build.MODEL

David Hedlund
  • 128,221
  • 31
  • 203
  • 222
  • I searched this name from android.os.build first,but I couldnt find anything userful.also I used this method below,it worked fine on my cellphone.But on Acer 500 tablet,it truely gathered the real serial number which also print on the marchine and it was not the name I get from adb. – wiseideal Sep 02 '11 at 04:02
0

Did you try

android.os.Build.MANUFACTURER
IgorGanapolsky
  • 26,189
  • 23
  • 116
  • 147
0

Just to further elaborate: Build.MODEL is a string which is the shortened version of android.os.Build.MODEL.

so String text = ("Build model " + Build.MODEL); results in text such as "SCH-I545" for newer phones or "Galaxy Nexus" for older phones. Depends on manufacturer and OS version.