As shown bellow you want to set APN and Username (optional),Password (optional) in your connection programmatically, if you are not set it in the device. This also caused to Tunnel Failed error.
public String HttpGET(String Url)
{
String AppendURL = ";deviceside=true ;apn=internet.com";
AppendURL +=";tunnelauthusername=user165;tunnelauthpassword=user165password";
try {
HttpConnection httpConnection = (HttpConnection) Connector.open(Url+AppendURL);
httpConnection.setRequestMethod(HttpConnection.GET);
InputStream inputStream = httpConnection.openInputStream();
StringBuffer sb = new StringBuffer();
int C;
while( -1 != (C = inputStream.read()))
{ sb.append((char)C); }
return sb.toString();
}
catch (Exception e)
{ return ""; }
}
Comments
Thanks for the info but I got couple of questions/doubts as listed below:
1. You're not changing APN Settings on the phone. Found in Option>Advance Options>TCP
2. What you're doing is adding the extra parameters to your connection string/URL that gives instruction to BB OS to route your connection via carrier's wap gateway.
3. If you know the correct values for a particular Blackberry device, then you can hardcode the various parameter values like you did in your code, but this need to be dynamic in order to make it work accross multiple carriers around the globe. What do you suggest about this?
Nice post though.
Regards,
Sameer.
And also using this method we can also allow blackberry application to go through wifi also,
;tunnelauthusername=user165;tunnelauthpassword=user165password
normally APN settings are unique to providers and they are rarely changed. thus you can have list of settings with you (ex:- as a file) and assign them according to the provider.