Welcome!

Welcome to the official BlackBerry Support Community Forums.

This is your resource to discuss support topics with your peers, and learn from each other.

inside custom component

Testing and Deployment

Reply
New Contributor
Posts: 4
Registered: ‎08-17-2012
My Device: Curve 9700
My Carrier: Programmer
Accepted Solution

Default user-agent through the Application as a Constant

Hi all,

 

I got this provider who gives me an SDK which is sealed and compiled so I can't change anything in it, and is asking me to provide a valid user-agent to their server, in this case I am not aware if I can set a custom default user agent to my application, this obviously using some system property to define dynamically this value.

 

My question is simple: Can I set a default user-agent? This will be used in all HttpConnection communications or HttpsConnection communications. This because I can't customize my provider SDK.

 

Please this would be a great lifesaver! Thank you very much in advance!

BlackBerry Development Advisor
Posts: 15,727
Registered: ‎07-09-2008
My Device: BlackBerry PRIV
My Carrier: Bell

Re: Default user-agent through the Application as a Constant

You can create a custom user-agent when creating a network connection from within your application.  Just add it as a header in the HttpConnection.  Just keep this in mind when choosing a user-agent.

 

HTTP transmits incorrectly when User-Agent includes "BlackBerry"

Mark Sohm
BlackBerry Development Advisor

Please refrain from posting new questions in solved threads.
Problem solved? Click the Accept As Solution button.
Found a bug? Report it using Issue Tracker
New Contributor
Posts: 4
Registered: ‎08-17-2012
My Device: Curve 9700
My Carrier: Programmer

Re: Default user-agent through the Application as a Constant

Hi thanks for your reply but is not answering what I asked for, is it a way to set a default user-agent value? kind like

 

System.setProperty("user-agent", "default custom dynamic value")

 

This one does not work, but is there a way? If there is none well I will have to see the way to decompile my providers SDK and create a fix in their classes.

 

Thanks a lot for your help!

BlackBerry Development Advisor
Posts: 15,727
Registered: ‎07-09-2008
My Device: BlackBerry PRIV
My Carrier: Bell

Re: Default user-agent through the Application as a Constant

No, there is no way to set a default user agent.  If you wish to customize this you'd need to do it with every connection your application initiates.

Mark Sohm
BlackBerry Development Advisor

Please refrain from posting new questions in solved threads.
Problem solved? Click the Accept As Solution button.
Found a bug? Report it using Issue Tracker
New Contributor
Posts: 4
Registered: ‎08-17-2012
My Device: Curve 9700
My Carrier: Programmer

Re: Default user-agent through the Application as a Constant

Thank You, Mark. By the way, why would an blackberry application carries no user-agent? This value is going empty in the whole application, shouldn't it has a default value at least? Thanks for your good response.

BlackBerry Development Advisor
Posts: 15,727
Registered: ‎07-09-2008
My Device: BlackBerry PRIV
My Carrier: Bell

Re: Default user-agent through the Application as a Constant

From what I've seen other than webservers serving web content to a browser, user-agent is rarely required when making an HTTP connection to a server application.  For that reason there is no use in sending a user agent each time over the wireless connection.  Plus there could be unexpected consequences in forcing the same user-agent on all applications.  

 

If you need it, it can be easily added to your application.

Mark Sohm
BlackBerry Development Advisor

Please refrain from posting new questions in solved threads.
Problem solved? Click the Accept As Solution button.
Found a bug? Report it using Issue Tracker
Highlighted
New Contributor
Posts: 4
Registered: ‎08-17-2012
My Device: Curve 9700
My Carrier: Programmer

Re: Default user-agent through the Application as a Constant

Hi mark,

 

This is for a measurement platform where every server call should has this information to feed an statistical data model that could be analized afterwards, you know kind like GA works but much more driven to mobile apps, so for this matter every http request to this service should bring up a dynamic but custom user-agent, kind like the one being build on every server request by a internet browser (e. Firefox, Safari, IE)

 

Thanks in advance,

Jose Villalobos