Thursday, September 10, 2009

Change APN Setting programmatically in Blackberry

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 "";      }
 } 
Post a Comment