手机终端UA探测

WURFL, the Wireless Universal Resource FiLe, is a Device Description Repository (DDR), i.e. a software component that maps HTTP Request headers to the profile of the HTTP client (Desktop, Mobile Device, Tablet, etc.) that issued the request.

相关地址:

http://wurfl.sourceforge.net/

http://sourceforge.net/projects/wurfl/files/

https://docs.scientiamobile.com/documentation/onsite/onsite-java-api

https://filex.scientiamobile.com/user/index#products/OnSite/Java_API/1.6.4.1

需要登录

https://github.com/WURFL/wurfl-cloud-client-java

云检测,支持不断更新

----------------------------以下是个人的设置-----------------------

package com.caiya.login.web.utils;

import org.apache.commons.lang3.Validate;

import javax.servlet.http.HttpServletRequest;
import java.util.regex.Pattern;

/**
 * 平台/设备检测工具类
 * Created by caiya on 16/1/13.
 */
public class DeviceDetectionUtils {


    /**
     * 判断"android","iphone","windows phone","meego","ipad"四个移动平台
     * This method parse the Http request to find the user-agent string. It
     * search the <code>User-Agent</code> header value.
     *
     * @param request The <code>HttpServletRequest</code> to parse. It must be not
     *                null value.
     * @return The user-agent string reported by the Http request.
     */
    public static boolean isMobile(HttpServletRequest request) {
        try {
            String user_agent = request.getHeader("User-Agent").toLowerCase();
            String[] deviceArray = new String[]{"android", "iphone", "windows phone", "meego", "ipad"};
            for (String device : deviceArray) {
                if (user_agent.indexOf(device) > 0) {
                    return true;
                }
            }
        } catch (Exception e) {
            return false;
        }
        return false;
    }



}


转载于:https://my.oschina.net/wnjustdoit/blog/604635

  • 0
    点赞
  • 0
    收藏
    觉得还不错? 一键收藏
  • 0
    评论

“相关推荐”对你有帮助么?

  • 非常没帮助
  • 没帮助
  • 一般
  • 有帮助
  • 非常有帮助
提交
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值