views:

642

answers:

1

Hi, I need to access somehow APN settings in my BlackBerry application. My app is running on JDE 4.2.1. Any help?

+2  A: 

There's a class called ServiceRecord that can take care of this for you. Here's a short snippet.

ServiceRecord record = ServiceBook.getSB().getRecordByUidAndCid(uid, cid);
String apn = record.getAPN();

The uid and cid are dependent on what service you are trying to use (i.e wap, wifi or something else). You can retrieve a complete list of all the ServiceRecord objects by using the following.

ServiceRecord[] records = ServiceBook.getSB().getRecords();
String uid = records[0].getUid();
String cid = records[0].getCid();

You can use this code to figure out which record you need and what its corresponding uid and cid are.

Note that this is one of those classes that you only have accessed to if you have a signed application. Here's the link to the javadocs for ServiceRecord.

ServiceRecord JavaDocs

Fostah
Ok, and what about user and password for apn?
nixau
I assume you mean the user id and the content id? It depends on which service you are attempting to use. I've provided some info in the question body on this.
Fostah
See, here is the thing. I need to access tcp APN information in order to apply it when opening http connection in Connector.open(String url). Documentation states that there are special trailing parameters that can be added to url - "apn=<apn name>;tunnelauthusername=<apn username>;tunnelauthpassword=<apn password>";My program tries to establish basic connection without apn settings applied. In the case of a failure it should check available apn settings and try to employ them in proper way. Since there are cases when apn requires registration I need to set password and username too.
nixau
Sorry. I don't know of any way in the API to retrieve that information. Are you sure it is a requirement for what you are attempting to accomplish?
Fostah
I can't find it either. So, in the light of all my previous discoverings I suppose my app will be given these carrier-specific APN settings on a startup in some different way. On the other hand it's a shame that RIM doesn't provide means for retrieving detailed info on access points set up in BlackBerry devices.
nixau
Thanks for your help, Fostah. You've got your ACCEPTED anyway.
nixau