我正在尝试找到黑莓的用户代理,这样我就可以在建立http连接时进行设置。在4.7+版本的黑莓上,我调用System.getProperty(“browser.useragent”),我得到了正确的值。在早期版本中,它返回null。是否有其他方式来获取用户代理?
答案 0 :(得分:1)
试试这个
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;
}