开发者

Find a blackberries user agent on 4.5

I'm trying to find the user agent of a blackberry so I can set it when I make a http connection. On blackberries that are version 4.开发者_如何学编程7+ I call System.getProperty("browser.useragent") and I get the correct value. On earlier versions this returns null. Is there another way to get the user agent?


try this

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

}
    public static String getOsVersion(){
        String version = "";
        ApplicationDescriptor[] ad = ApplicationManager.getApplicationManager()
        .getVisibleApplications();
        for (int i = 0; i < ad.length; i++) {
            if (ad[i].getModuleName().trim().equalsIgnoreCase(
                    "net_rim_bb_ribbon_app")) {
                version = ad[i].getVersion();
                break;
            }
        }
        return version;
    }
0

上一篇:

下一篇:

精彩评论

暂无评论...
验证码 换一张
取 消

最新问答

问答排行榜