gpt4 book ai didi

java - 什么是更好的: detecting device using its size or user agent string?

转载 作者:行者123 更新时间:2023-12-01 13:45:16 24 4
gpt4 key购买 nike

我需要区分移动/平板电脑和桌面浏览器,我想知道是解析用户代理字符串更好还是查看设备的宽度和高度来确定相同的?哪种方法更可取?为什么?

TIA

最佳答案

您通常需要同时执行这两项操作。用户代理不足以区分 Android 手机和平板电脑。

请参阅此链接,了解 Google Web Toolkit 的工作原理: https://code.google.com/p/google-web-toolkit/source/browse/trunk/samples/mobilewebapp/src/com/google/gwt/sample/mobilewebapp/FormFactor.gwt.xml?r=10041

基本上,您检查用户代理是否为“iphone”或“ipad”,否则检查“android”(如果是这样,请使用大小来确定移动设备/平板电脑),否则它是“桌面”。

关于java - 什么是更好的: detecting device using its size or user agent string?,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/20411323/

24 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com