How to get my android device name in my android pr

2019-05-10 07:42发布

问题:

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.

回答1:

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);



回答2:

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



回答3:

Did you try

android.os.Build.MANUFACTURER


回答4:

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.



标签: android adb ddms