java determine the phone or computer access

Many blog writing is very complex, not specifically to see. I only use the following lines of code

        String userAgent = req.getHeader("user-agent");
        if (userAgent.indexOf("Android") != -1) {
            //安卓
        } else if ((userAgent.indexOf("iPhone") != -1) || (userAgent.indexOf("iPad") != -1)) {
            //苹果
        } else {
            //电脑
        }

 

Guess you like

Origin www.cnblogs.com/yanan7890/p/11940063.html