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 tab开发者_StackOverflow中文版let 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.
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);
android.os.Build
contains device info. You're probably interested in Build.MODEL
Did you try
android.os.Build.MANUFACTURER
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.
精彩评论