Blackberry System.getProperty ("browser.useragent")

We can get the user agent from the device by calling

System.getProperty ("browser.useragent")

This method is available for OS 4.7 +

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

It works like a charm.

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

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

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

+3
source share
2 answers

You can check this in the simulator of your choice by creating an application that registers or prints to display the value of System.getProperty ("browser.useragent"), then make a noticeable change in the simulator.

+1
source

that's 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 create a useragent using 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();
}
0
source

All Articles