08-17-2012 02:41 PM
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!
Solved! Go to Solution.
08-20-2012 02:02 PM
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.
08-21-2012 10:29 AM
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!
08-21-2012 11:02 AM
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.
08-21-2012 12:08 PM
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.
08-21-2012 01:03 PM
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.
08-21-2012 02:19 PM
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,