BlackBerry Forums Support Community               

Closed Thread
 
LinkBack Thread Tools
Old 08-06-2008, 05:32 PM   #1 (permalink)
Thumbs Must Hurt
 
Join Date: Apr 2007
Location: Cincinnati, OH
Model: 8700c
PIN: N/A
Carrier: Cingular
Posts: 87
Post Thanks: 0
Thanked 0 Times in 0 Posts
Default Profile (MIDP-2.0), Configuration (CLDC-1.1) - How to get this info programmatically

Please Login to Remove!

Hi Folks,

I'm trying to build a user-agent string in code. I want it to look something like this:

"Blackberry8700/4.1.0 Profile/MIDP-2.0 Configuration/CLDC-1.1 VendorID/102"

I'm able to get my model number, and vendor id, but I can't seem to find how to find my OS version, nor my Profile nor my Configuration programmatically.

Can anyone help me fill in the ???'s?

myString = "Blackberry" + DeviceInfo.getDeviceName() + "/" + ??? + "Profile/" + ??? + "Configuration/" + ??? + "VendorID/" + Branding.getVendorId();

P.S. DeviceInfo.getPlatformVersion() doesn't return the OS version like I thought it would.
Offline  
Old 08-06-2008, 06:51 PM   #2 (permalink)
BlackBerry Extraordinaire
 
Join Date: Mar 2008
Location: Austin, TX
Model: 9700
PIN: N/A
Carrier: T-Mobile
Posts: 1,644
Post Thanks: 0
Thanked 34 Times in 33 Posts
Default

Try this:

Get an instance of ApplicationManager, get the list of visible applications (ApplicationDescriptor[]), and search the list for "net_rim_bb_ribbon_app".

Then call getVersion() on this app descriptor.
Offline  
Old 08-07-2008, 10:24 AM   #3 (permalink)
Thumbs Must Hurt
 
Join Date: Apr 2007
Location: Cincinnati, OH
Model: 8700c
PIN: N/A
Carrier: Cingular
Posts: 87
Post Thanks: 0
Thanked 0 Times in 0 Posts
Thumbs up Thanks!

Thanks Doug!

That worked perfectly.

Code:
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;
    }
}
Any idea how to get the Profile (MIDP-2.0) and Configuration ( CLDC-1.1)?
Seems like there should be a JvmInfo class or something like that, but I haven't found anything like that.
Offline  
Old 08-07-2008, 10:59 AM   #4 (permalink)
BlackBerry Extraordinaire
 
Join Date: Mar 2008
Location: Austin, TX
Model: 9700
PIN: N/A
Carrier: T-Mobile
Posts: 1,644
Post Thanks: 0
Thanked 34 Times in 33 Posts
Default

Have you looked at the DeviceInfo class?
Offline  
Old 08-07-2008, 11:10 AM   #5 (permalink)
Thumbs Must Hurt
 
Join Date: Apr 2007
Location: Cincinnati, OH
Model: 8700c
PIN: N/A
Carrier: Cingular
Posts: 87
Post Thanks: 0
Thanked 0 Times in 0 Posts
Default

Yeah, that's exactly where I thought it would be. But, I don't see anything like that in there. Thanks for the idea though
Offline  
Old 08-08-2008, 12:38 AM   #6 (permalink)
Thumbs Must Hurt
 
Join Date: Apr 2005
Model: 950
Carrier: T-Mobile
Posts: 185
Post Thanks: 0
Thanked 0 Times in 0 Posts
Default

How about System.properties?
Offline  
Old 08-12-2008, 09:07 AM   #7 (permalink)
Thumbs Must Hurt
 
Join Date: Apr 2007
Location: Cincinnati, OH
Model: 8700c
PIN: N/A
Carrier: Cingular
Posts: 87
Post Thanks: 0
Thanked 0 Times in 0 Posts
Default

Thanks for the idea.
I've tried System.getProperty() with all the arguments I can think of, including the most obvious ones:

System.getProperty( "configuration" )
System.getProperty( "Configuration" )
System.getProperty( "CONFIGURATION" )
System.getProperty( "profile" )
System.getProperty( "Profile" )
System.getProperty( "PROFILE" )

Unfortunately they all return null.

Oh well. Thanks for your help though
Offline  
Old 08-12-2008, 04:00 PM   #8 (permalink)
CrackBerry Addict
 
Join Date: May 2005
Location: Golden, CO US
Model: 9700
Carrier: ATT
Posts: 684
Post Thanks: 0
Thanked 0 Times in 0 Posts
Default

The following properties should get you what you want...

microedition.configuration
microedition.profiles
Offline  
Old 08-13-2008, 09:04 AM   #9 (permalink)
Thumbs Must Hurt
 
Join Date: Apr 2007
Location: Cincinnati, OH
Model: 8700c
PIN: N/A
Carrier: Cingular
Posts: 87
Post Thanks: 0
Thanked 0 Times in 0 Posts
Thumbs up Thanks!

Code:
String s1 = System.getProperty( "microedition.configuration" );            
String s2 = System.getProperty( "microedition.profiles" );
Thanks RemyJ!
Those were exactly what I needed.
(I couldn't find it in the documentation anywhere, but now that I know what to look for a quick google search gives me this handy page):

//http://developers.sun.com/mobility/midp/questions/properties/index.html

Also, thanks jonberry!
You were right about system properties.
Offline  
Old 08-13-2008, 09:29 AM   #10 (permalink)
Thumbs Must Hurt
 
Join Date: Apr 2007
Location: Cincinnati, OH
Model: 8700c
PIN: N/A
Carrier: Cingular
Posts: 87
Post Thanks: 0
Thanked 0 Times in 0 Posts
Thumbs up The whole enchilada...

BTW - For anyone who might be looking for the same thing, here's how to build a string which looks something like this:

Blackberry7290/4.1.0.139 Profile/MIDP-2.0 Configuration/CLDC-1.1 VendorID/-1

Code:
String userAgent = "Blackberry" + DeviceInfo.getDeviceName() + "/" + getOsVersion() + " Profile/" + System.getProperty( "microedition.profiles" ) + " Configuration/" + System.getProperty( "microedition.configuration" ) + " VendorID/" + Branding.getVendorId();
You'll need this method (or something like it):

Code:
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; 
}
(Of course, you'll also need to import these):
Code:
import net.rim.device.api.system.ApplicationDescriptor;
import net.rim.device.api.system.ApplicationManager;
import net.rim.device.api.system.Branding;
import net.rim.device.api.system.DeviceInfo;
Thanks again for everyone's help
Offline  
Closed Thread


Thread Tools

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

vB code is On
Smilies are On
[IMG] code is On
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are On





Copyright 2004-2014 BlackBerryForums.com.
The names RIM and BlackBerry are registered Trademarks of BlackBerry Inc.