BlackBerry Forums Support Community               

Closed Thread
 
LinkBack Thread Tools
Old 05-17-2011, 05:36 AM   #1 (permalink)
New Member
 
Join Date: May 2011
Model: Curve
PIN: N/A
Carrier: Kyivstar
Posts: 2
Post Thanks: 0
Thanked 0 Times in 0 Posts
Default wifi: works in browser and apps, but not in our program

Please Login to Remove!

Hello everyone,

we have just started to write Blackberry apps and got strange situation. Our apps work with mobile internet (GPRS, 3G, EDGE) but are not working using wifi connection.

I have tried to change all the settings. But still usually it is just "Tunnel failure" or "connection timed out". The same is with HTTPDemo example.

Could someone help and explain what it is with Blackberry and WiFi?

StreamConnection s = null;
s = (StreamConnection)Connector.open(getUrl() +";interface=wifi");
HttpConnection httpConn = (HttpConnection)s;

int status = httpConn.getResponseCode();

if (status == HttpConnection.HTTP_OK)
{
// Is this html?
String contentType = httpConn.getHeaderField(HEADER_CONTENTTYPE);
boolean htmlContent = (contentType != null && contentType.startsWith(CONTENTTYPE_TEXTHTML));

InputStream input = s.openInputStream();

byte[] data = new byte[256];
int len = 0;
int size = 0;
StringBuffer raw = new StringBuffer();

while ( -1 != (len = input.read(data)) )
{
// Exit condition for the thread. An IOException is
// thrown because of the call to httpConn.close(),
// causing the thread to terminate.
if ( _stop )
{
httpConn.close();
s.close();
input.close();
}
raw.append(new String(data, 0, len));
size += len;
}

raw.insert(0, "bytes received]\n");
raw.insert(0, size);
raw.insert(0, '[');
content = raw.toString();

if ( htmlContent )
{
content = prepareData(raw.toString());
}
input.close();
}
else
{
content = "response code = " + status;
}
s.close();
}
catch (IOCancelledException e)
{
System.out.println(e.toString());
return;
}
catch (IOException e)
{
errorDialog(e.toString());
return;
}
Offline  
Old 05-17-2011, 08:21 AM   #2 (permalink)
BlackBerry Extraordinaire
 
Join Date: Jan 2006
Model: LEZ10
OS: 10.0.10
Carrier: Rogers CA
Posts: 1,704
Post Thanks: 20
Thanked 77 Times in 68 Posts
Default Re: wifi: works in browser and apps, but not in our program

Ok, first please read this post so the code you post will be easier to read.

1. What OS version are you using?

2. Do you have a BlackBerry Data Plan on the device?

3. Have you configured the appropriate APN values for your carrier?
__________________
My other Blackberry is a PlayBook.
Offline  
Old 05-17-2011, 09:23 AM   #3 (permalink)
New Member
 
Join Date: May 2011
Model: Curve
PIN: N/A
Carrier: Kyivstar
Posts: 2
Post Thanks: 0
Thanked 0 Times in 0 Posts
Default Re: wifi: works in browser and apps, but not in our program

@hrbuckley
thanks
Here are the answers to your questions:
1. 5.0
2. It works now even without Data Plan (with the code below).
3. Is it really necessary for the wifi connections?

PHP Code:

HttpConnection connection 
null;
if (
WLANInfo.getWLANState() == WLANInfo.WLAN_STATE_CONNECTED) {
         
connection = (HttpConnectionConnector.open(url";interface=wifi",
         
Connector.READ_WRITE,true);
} else {
         
connection = (HttpConnectionConnector.open(url+";deviceside=true"Connector.READ_WRITE,true);


Last edited by maykivets : 05-17-2011 at 09:26 AM. Reason: code formatting
Offline  
Old 05-17-2011, 04:58 PM   #4 (permalink)
BlackBerry Extraordinaire
 
Join Date: Jan 2006
Model: LEZ10
OS: 10.0.10
Carrier: Rogers CA
Posts: 1,704
Post Thanks: 20
Thanked 77 Times in 68 Posts
Default Re: wifi: works in browser and apps, but not in our program

Glad to hear you got it working.

2. Depending on the carrier and the OS level Wi-Fi won't work without one.
3. No, but again, depending on the OS level and carrier support the else clause from your code above won't work without the APN configured, usually the earlier OSes need an APN.
__________________
My other Blackberry is a PlayBook.
Offline  
Closed Thread


Thread Tools

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

vB code is On
Smilies are On
[IMG] code is On
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are On

Similar Threads for: wifi: works in browser and apps, but not in our program
Thread Thread Starter Forum Replies Last Post
HELP: My torch browser will not work on wifi. hyoslvr BlackBerry Help 16 06-25-2011 09:53 PM
BB Browser won't go online but Opera works! *UNUSUAL* Farsight General 8500 Series Discussion - Gemini 6 09-11-2010 12:33 AM
WIFI connects,setting = hotspot browser,browser still tries to go to tmobile browser Billy_Gunn General 8900 Series Discussion - Javelin 3 05-15-2010 03:18 PM
Wifi works great until I use Facebook Mark PPG Social Networking 3 02-19-2010 09:26 AM
Email over WIFI on BES sniffs BES Admin Corner 5 06-05-2008 06:51 AM





Copyright 2004-2014 BlackBerryForums.com.
The names RIM and BlackBerry are registered Trademarks of BlackBerry Inc.