Android获取设备信息(利用反射)

public static String getSystemProperties(String prop, String def_value) {

		try {
			Class<?> cl = Class.forName("android.os.SystemProperties");
			Object invoker = cl.newInstance();
			Method m = cl.getMethod("get", new Class[] { String.class,
					String.class });
			return (String) m.invoke(invoker, new Object[] { prop, def_value });
		} catch (Exception e) {

		}

		return def_value;
	}

	Field field = android.os.Build.class.getField("DISPLAY_HARDWARE");
	deviceInfo.HWVersion = (String) field.get(null);

你可能感兴趣的:(android,反射,获取设备信息)