黑莓 System.getProperty(“browser.useragent”)

发布于 2024-11-15 16:29:07 字数 406 浏览 1 评论 0原文

我们可以通过调用从设备获取用户代理

System.getProperty("浏览器.useragent")

此方法适用于 OS 4.7 +

我只在一些 Blackberry 模拟器上测试过:9530 (os 4.7)、9800 (os 6.0.0)

它起到了魅力的作用。

但据我所知,在真实设备上,如果用户更改黑莓浏览器,向服务器发出的http请求中的用户代理将会更改。例如,一些黑莓设备使用 Firefox 浏览器。

因此我想知道,如果在真实设备上更改浏览器设置,当我们调用 System.getProperty("browser.useragent") 时,返回值会改变吗???

有人在真机上测试过吗? 或者有人知道答案吗?

We are able to get the user agent from device via calling

System.getProperty("browser.useragent")

This method is available for OS 4.7 +

I only tested it on some of the Blackberry simulators: 9530 (os 4.7), 9800 (os 6.0.0)

It works as a charm.

But as far as I know that on real devices, if user changes the blackberry browser, the user agent in the http request to server will be changed. For instance, some of the blackberry devices use Firefox browser.

Therefore I would like to know, if browser setting is changed on the real device, when we call System.getProperty("browser.useragent"), will the return value change???

Has anyone tested on the real device?
or does anyone know the anwser.

如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

扫码二维码加入Web技术交流群

发布评论

需要 登录 才能够评论, 你可以免费 注册 一个本站的账号。

评论(2

-柠檬树下少年和吉他 2024-11-22 16:29:07

您可以在您选择的模拟器中对此进行测试,方法是创建一个应用程序来记录或打印以屏幕显示 System.getProperty("browser.useragent") 的值,然后在模拟器中进行您注意到的更改。

You could test this out in a Simulator of your choice by creating an App that logs or prints to screen the value of System.getProperty("browser.useragent") then making your noted change in the simulator.

哀由 2024-11-22 16:29:07

这是一个示例:

public static String getSystemUserAgent(){
    String agent = "";
    if(System.getProperty("browser.useragent")!=null){
        agent = System.getProperty("browser.useragent");
    }else if(GI.isScreenSmall()){
        agent = "BlackBerry8100/4.5.0.180 Profile/MIDP-2.0 Configuration/CLDC-1.1 VendorID/215";
    }else{
        agent = "BlackBerry8300/4.2.2Profile/MIDP-2.0 Configuration/CLDC-1.1 VendorID/107UP.Link/6.2.3.15.0";
    }
    return agent;
    }

您可以使用此方法构造 UserAgent

private static String getUserAgent() {
      String userAgent = "Blackberry" + DeviceInfo.getDeviceName() + "/" +
      DeviceInfo.getSoftwareVersion() + " Profile/" + System.getProperty(
         "microedition.profiles" ) + " Configuration/" + System.getProperty(
         "microedition.configuration" ) + " VendorID/" +
         Branding.getVendorId();
}

this is an example:

public static String getSystemUserAgent(){
    String agent = "";
    if(System.getProperty("browser.useragent")!=null){
        agent = System.getProperty("browser.useragent");
    }else if(GI.isScreenSmall()){
        agent = "BlackBerry8100/4.5.0.180 Profile/MIDP-2.0 Configuration/CLDC-1.1 VendorID/215";
    }else{
        agent = "BlackBerry8300/4.2.2Profile/MIDP-2.0 Configuration/CLDC-1.1 VendorID/107UP.Link/6.2.3.15.0";
    }
    return agent;
    }

you can construct the UserAgent with this method

private static String getUserAgent() {
      String userAgent = "Blackberry" + DeviceInfo.getDeviceName() + "/" +
      DeviceInfo.getSoftwareVersion() + " Profile/" + System.getProperty(
         "microedition.profiles" ) + " Configuration/" + System.getProperty(
         "microedition.configuration" ) + " VendorID/" +
         Branding.getVendorId();
}
~没有更多了~
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文