Android手机或Android平板电脑检测通过HTTP头 [英] Android phone or Android tablet detection by http headers

查看:231
本文介绍了Android手机或Android平板电脑检测通过HTTP头的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

有没有一种方法来检测用户是否访问来自搭载Android平板电脑或手机网站在服务器端?

Is there a way to detect whether user is accessing your website from android powered tablet or phone on the server side?

我不拥有任何Android设备,所以它不可能对我来说,测试这些设备发送什么样的头。

I don't own any android devices, so it's not possible for me to test what kind of headers those devices send.

在我的研究,我发现:
- 许多方式使用javascript检测到它。但是那(恕我直言)不是最好的那一刻,当你决定哪些网页版应该发送到客户端。我每个版本preFER服务器基于客户端发送的HTTP标头。
- 收集和设备类型排序的HTTP标头的数据库。但我可以靠这个?也有支付解决方案,可以更realibe,但我preFER免费的解决方案。

In my research I found: - many ways to detect it using javascript. But thats (IMHO) not the best moment, when you decide what web version should be sent to client. I prefer to server each version based on http headers sent by client. - database of http headers collected and sorted by device type. But can I rely on this? Also there are paid solution that can be more realibe, but I prefer free solutions.

有没有其他的解决办法?你能推荐一个吗?为什么?

Is there any other solution? Can you recommend one? And why?

推荐答案

他们提到这对开发者博客时,片刚出来:

They mentioned this on the developer blog when tablets first came out:

http://android-developers.blogspot.com/2010/12/android-browser-user-agent-issues.html

唯一的区别是,移动设备是从用户代理除去。

The only difference is that "Mobile" is removed from the user agent.

修改:这是为Galaxy Tab和传单用户代理

Edit: These are the user agents for the Galaxy Tab and Flyer

Mozilla/5.0 (Linux; U; Android 3.1; en-us; GT-P7510 Build/HMJ37) AppleWebKit/534.13 (KHTML, like Gecko) Version/4.0 Safari/534.13

Mozilla/5.0 (Linux; U; Android 3.2.1; en-gb; HTC Flyer P510e Build/HTK75C) AppleWebKit/534.13 (KHTML, like Gecko) Version/4.0 Safari/534.13

这篇关于Android手机或Android平板电脑检测通过HTTP头的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆