Welcome to OGeek Q&A Community for programmer and developer-Open, Learning and Share
Welcome To Ask or Share your Answers For Others

Categories

0 votes
220 views
in Technique[技术] by (71.8m points)

Android phone or Android tablet detection by http headers

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?

See Question&Answers more detail:os

与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…
Welcome To Ask or Share your Answers For Others

1 Reply

0 votes
by (71.8m points)

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

与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…
OGeek|极客中国-欢迎来到极客的世界,一个免费开放的程序员编程交流平台!开放,进步,分享!让技术改变生活,让极客改变未来! Welcome to OGeek Q&A Community for programmer and developer-Open, Learning and Share
Click Here to Ask a Question

...