Where did you install Firefox from? Help Mozilla uncover 3rd party websites that offer problematic Firefox installation by taking part in our campaign. There will be swag, and you'll be featured in our blog if you manage to report at least 10 valid reports!

搜索 | 用户支持

防范以用户支持为名的诈骗。我们绝对不会要求您拨打电话或发送短信,及提供任何个人信息。请使用“举报滥用”选项报告涉及违规的行为。

Learn More

From the user agent, how do I know it is a Android device?

  • 2 个回答
  • 13 人有此问题
  • 6 次查看
  • 最后回复者为 jameslee

more options

we have a Android game site where we detect the device type and show what games are available.

But on Firefox for mobile, there is no indication in the useragent of what the handset is. In fact it is the same as the firefox 4 desktop browser.

The firefox 4 mobile useragent is Mozilla/5.0 (Android; Linux armv7l; rv:2.1) Gecko/20110318 Firefox/4.0b13pre Fennec/4.0

While the useragent of default browser is Mozilla/5.0 (Linux; U; Android 2.2.1; en-gb; GT-I9000 Build/FROYO) AppleWebKit/533.1 (KHTML, like Gecko) Version/4.0 Mobile Safari/533.1

we have a Android game site where we detect the device type and show what games are available. But on Firefox for mobile, there is no indication in the useragent of what the handset is. In fact it is the same as the firefox 4 desktop browser. The firefox 4 mobile useragent is Mozilla/5.0 (Android; Linux armv7l; rv:2.1) Gecko/20110318 Firefox/4.0b13pre Fennec/4.0 While the useragent of default browser is Mozilla/5.0 (Linux; U; Android 2.2.1; en-gb; GT-I9000 Build/FROYO) AppleWebKit/533.1 (KHTML, like Gecko) Version/4.0 Mobile Safari/533.1

所有回复 (2)

more options

If the User-Agent contains "Fennec/" then it is Firefox for mobile. If it contains "Android" then it is running on an Android device.

We have an open request to add more device info to the User-Agent header. For details, see: https://bugzilla.mozilla.org/show_bug.cgi?id=625238

We'll consider this request, but we must balance it against user privacy, and attacks like browser fingerprinting. For now, in cases where you don't detect a known device from the User-Agent header, you can ask the user instead (for example, have them choose from a list of devices). This will also benefit Android users who have changed their browsers' User-Agent headers for various reasons.

more options

This is very much a solution and many people do use it. However, we are always working to provide the most seamless experience for the user.

Also, I understand that Mozilla may have higher standards but even the default Android browsers, and other 3rd party browsers like opera include the device string into the user-agent.

When developing apps that are very specific to devices, having this device info string works wonders for us.