01-18-2013 11:23 AM
According to what I've been seeing already ha way to detect what is connected. But HTTPDemo should not give in mobile phone?
I just tried to run the application on the mobile phone with wifi option and set the "deviceside = false" and yet the message that appears is "java.io.IOException" I do not understand why it does not work! : S
01-18-2013 11:50 AM
The modify code is:
HttpConnection httpConn = (HttpConnection)Connector.open(getUrl()+";interfac
01-18-2013 11:53 AM
You might remember this KB article that I referenced previously.
Have another look through this and see what each of the connection strings actually means.
For WiFi you need
";interface=wifi"
Note that these must be typed exactly as you see them. So "deviceside = false" won't work because it does not have a ";" to start and there are spaces in it. You should use
";deviceside=false"
This is for BES/MDS connections, I doubt your phone is a BES phone.
But I really recommend that you do not try this way. Use ConnectionFactory.
01-21-2013 10:45 AM
I've been researching the FactoryConnection and tried to implement but not how to get the text of this connection!
My code is:
//preferred transport types
int[] preferredTransportTypes = {TransportInfo.TRANSPORT_TCP_WIFI, TransportInfo.TRANSPORT_MDS,
TransportInfo.TRANSPORT_WAP2, TransportInfo.TRANSPORT_BIS_B, TransportInfo.TRANSPORT_TCP_CELLULAR,
TransportInfo.TRANSPORT_WAP};
//set preference in connection factory
ConnectionFactory factory = new ConnectionFactory();
factory.setPreferredTransportTypes(preferredTransp
factory.setAttemptsLimit(3);
//create connection using connectionDescriptor
ConnectionDescriptor conDescriptor = factory.getConnection(url);
HttpConnection httpConnection=null;
if(conDescriptor !=null){
httpConnection = (HttpConnection) conDescriptor.getConnection();
transportType = conDescriptor.getTransportDescriptor().getTranspor
}
01-21-2013 11:18 AM
If you have looked at HttpDemo (sorry I think I called it htmlDemo), you will see these lines:
StreamConnection s = null;
s = (StreamConnection)Connector.open(getUrl());
HttpConnection httpConn = (HttpConnection)s;
Basically after this line in your code:
httpConnection = (HttpConnection) conDescriptor.getConnection();
you have an HTTP connection. And so the processing continues like HttpDemo, i.e. get response code and then read the input stream.
BTW, I recommend IOUtilities.streamToBytes as a quick way to read the entire Stream in.
Hope this helps.
01-21-2013 11:44 AM
Have a working code that I can show to see if I can understand putting it to work right?
Have tou is all confused and I really need to put this to work ASAP!
01-21-2013 12:38 PM
01-21-2013 12:50 PM
I had already found this example and what brings me back is the number 302, which does not know what it means!
01-21-2013 05:07 PM
Is this the response code you are getting?
If so, use the search facility here or use your favorite Internet search engine and look for Http code 302. Hopefully that will explain it.
With redirects you need to chase down the actual address yourself - Browsers do this for you but when getting the data yourself you need to do it.
01-21-2013 05:14 PM
But with this code should not show the text received?