02-05-2013 09:37 AM
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,applic ation/xml,application/xhtml+xml,text/html;q=0.9,te xt/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