How to get my android device name in my android pr

2019-05-10 06:58发布

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.

标签: android adb ddms
4条回答
We Are One
2楼-- · 2019-05-10 07:37

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

查看更多
forever°为你锁心
3楼-- · 2019-05-10 07:39

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.

查看更多
啃猪蹄的小仙女
4楼-- · 2019-05-10 08:02

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

查看更多
做自己的国王
5楼-- · 2019-05-10 08:03

Did you try

android.os.Build.MANUFACTURER
查看更多
登录 后发表回答