wurfl手机型号读取

wurfl很实用,手机型号比较全,省去自己去收集各种信息了。。。
读取使用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万多手机型号....
对于如何配置,官网说的比较清楚.

你可能感兴趣的:(PHP,.net,xml,OS)