Android phone or Android tablet detection by http headers

无人久伴 提交于 2019-12-25 18:47:31

问题


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

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

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?


回答1:


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.

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



回答2:


WURFL should do what you want.




回答3:


If you don't want to load the whole device db but still want more reliable matching, WURFL has a cloud product now (and it has a free offering that may be suitable for your needs):

http://www.scientiamobile.com/cloud



来源:https://stackoverflow.com/questions/9829716/android-phone-or-android-tablet-detection-by-http-headers

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!