浏览 4253 次
锁定老帖子 主题:wurfl手机型号读取
精华帖 (0) :: 良好帖 (0) :: 新手帖 (0) :: 隐藏帖 (0)
|
|
---|---|
作者 | 正文 |
发表时间:2009-12-11
最后修改:2009-12-11
读取使用API有很多种方式,show下偶的吧.. ListManager listManager = ObjectsManager.getListManagerInstance(); TreeMap map = listManager.getDeviceGroupedByBrand(); if (map != null) { Set set = map.keySet(); //厂商名称 String brandName = ""; //手机型号 String modelName = ""; int load_company_num = 0; int load_phone_num = 0; for (Iterator iterator = set.iterator(); iterator.hasNext();) { Object brandName_obj = iterator.next(); brandName = brandName_obj.toString(); load_company_num ++; Object phoneMap_obj = map.get(brandName_obj); if (phoneMap_obj instanceof TreeMap) { TreeMap phoneMap = (TreeMap) phoneMap_obj; Set phoneSet = phoneMap.keySet(); l for (Iterator iterator1 = phoneSet.iterator(); iterator1.hasNext();) { Object modelName_obj = iterator1.next(); modelName = modelName_obj.toString(); Object device_obj = phoneMap.get(modelName_obj); if (device_obj instanceof WurflDevice) { WurflDevice device = (WurflDevice) device_obj; String agent_id = device.getId(); CapabilityMatrix cm = ObjectsManager.getCapabilityMatrixInstance(); //分辨率 宽 String w = cm.getCapabilityForDevice(agent_id, "resolution_width"); //分辨率 高 String h = cm.getCapabilityForDevice(agent_id, "resolution_height"); //操作系统 String os = cm.getCapabilityForDevice(agent_id, "device_os"); //os 版本 String os_ver = cm.getCapabilityForDevice(agent_id, "device_os_version"); load_phone_num ++; System.out.println("brandName = " + brandName); System.out.println("modelName = " + modelName ); System.out.println("w= " + w); System.out.println("h= " + h); System.out.println("os= " + os); System.out.println("os_ver= " + os_ver); } } } } System.out.println("map.size() = " + map.size()); System.out.println("load_company_num = " + load_company_num); System.out.println("load_phone_num = " + load_phone_num); } 其中 cm.getCapabilityForDevice 能获得参数,参考http://wurfl.sourceforge.net/help_doc.php wurfl.xml里面有1万多手机型号.... 对于如何配置,官网说的比较清楚. 声明:ITeye文章版权属于作者,受法律保护。没有作者书面许可不得转载。
推荐链接
|
|
返回顶楼 | |