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;
}
精彩评论