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

Java Development

Reply
Highlighted
Contributor
Posts: 37
Registered: ‎07-23-2011
My Device: 9700
My Carrier: Airtel

Network connection problem

In my application used for  Httpconnection .To acces the url I have been using following  classes (TransportDetective and URLFactory) as widly used one.

TransportDetective _td = new TransportDetective();
	private int _availableTransports = 0;

		_availableTransports = _td.getAvailableTransportCoverage(); 
		Url = getFullURL("http://www.google.com", _availableTransports); 
	    	HttpConnection conn = (HttpConnection)Connector.open(Url,Connector.READ | Connector.WRITE);
	    	conn.setRequestProperty("Content-Type", "application/x-www-form-urlencoded");
	    	conn.setRequestProperty("Accept","text/html,application/xml,application/xhtml+xml,text/html;q=0.9,text/plain;q=0.8,image/png,*/*;q=0.5");
	    	conn.setRequestProperty(HttpHeaders.HEADER_ACCEPT_CHARSET, "UTF-8");
	    	conn.setRequestMethod(HttpConnection.GET); 
	    	 int response=conn.getResponseode();
		 if(responsecode==HttpConnection.HTTP_OK)
		 {
			//...code for handling the response...
		 }

 I have been using wifi connection the below method is working fine in our end . Client said he got the  Exception: net.rim.device.internal.io.Critical||OException .

 

public static String getFullURL(String requestedURL, int transport) {
		URLFactory urlFactory = new URLFactory(requestedURL);
		if ( (transport & TransportDetective.TRANSPORT_TCP_WIFI) > 0 ) {
			return urlFactory.getHttpTcpWiFiUrl();
		} else
			if ( (transport & TransportDetective.TRANSPORT_BIS_B) > 0 ) {
				return urlFactory.getHttpBisUrl();
			} else
				if ( (transport & TransportDetective.TRANSPORT_TCP_CELLULAR) > 0 ) {
					// Only here for Simulator
					return urlFactory.getHttpDefaultUrl() + ";deviceside=true";
				}else 
					if ( (transport & TransportDetective.TRANSPORT_MDS) > 0 ) {
						return urlFactory.getHttpMdsUrl(false);
					} 					
					else {  
						return urlFactory.getHttpDefaultUrl();    
				}
	}

 I have modified the  above code and it's works correctly in client device whereas in my device get works fine .But we need to make all type of connection support to work properly in our app. Since we are using wifi supporeted connection. how can  change the above code.Please suggest me.

	public static String getFullURL(String requestedURL, int transport) {
		URLFactory urlFactory = new URLFactory(requestedURL);		
		  		return urlFactory.getHttpTcpWiFiUrl();             
   
	}

 Thanks