【发布时间】:2011-04-02 23:09:24
【问题描述】:
我正在尝试查找黑莓的用户代理,以便在建立 http 连接时进行设置。在 4.7+ 版本的黑莓上,我调用 System.getProperty("browser.useragent") 并得到正确的值。在早期版本中,这将返回 null。还有其他获取用户代理的方法吗?
【问题讨论】:
标签: blackberry user-agent httpconnection
我正在尝试查找黑莓的用户代理,以便在建立 http 连接时进行设置。在 4.7+ 版本的黑莓上,我调用 System.getProperty("browser.useragent") 并得到正确的值。在早期版本中,这将返回 null。还有其他获取用户代理的方法吗?
【问题讨论】:
标签: blackberry user-agent httpconnection
试试这个
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;
}
【讨论】: