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. New to the forum? Please visit the ‘Getting Started’ link below.
inside custom component

Java Development

Reply
New Contributor
reachak
Posts: 3
Registered: ‎08-05-2011
My Carrier: Rogers

Application developed by us only works on WIFI and FREEZES On Data network

Hello,

I have posted my query on Development forum but i was asked to post here. We have developed an app for Blackberry app world and it works perfectly fine on WIFI, but when we disable WIFI and ONLY keep DATA on, the app freezes and terminates after a while.

 

Other 3rd party apps and youtube, FB, etc works fine on Data and Wifi, only our App does not.

 

Is there something in the coding that we have to do, for it to work on Data?

Also, when the device we used, was on PDA plan, it worked fine on Data network too, but as soon as we upgraded our plan to Blackberry plan, same issue - FREEZES !!

 

Any help would be appreciated. We have tried locked and unlocked phones, both, but issue does not get solved.

 

Thanks

AK

Please use plain text.
Developer
peter_strange
Posts: 17,952
Registered: ‎07-14-2008

Re: Application developed by us only works on WIFI and FREEZES On Data network

There are unfortunately a variety of ways for a Blackberry to get data as this video will tell you:

 

http://supportforums.blackberry.com/t5/Java-Development/Networking-Transports-II/ta-p/446742

 

There is also a wide variety of code around to get data, some of which works in all OS's, some of which is restricted to the later level OS's.  The best approach for you to manage the data connection reliably does depend on what devices and OS's you are targeting.  Can you let us know?

 

Be aware that most RIM applications will use the underlying BlackBerry infrastructure to get data, which is called BIS-B on consumer phones.  There are hoops to work around to get access to BIS-B, but I suspect this is how your other apps are communicating. 

Please use plain text.
Contributor
zahmed70
Posts: 13
Registered: ‎04-01-2011
My Carrier: Bell.ca

Re: Application developed by us only works on WIFI and FREEZES On Data network

Actually whats happening is that the app works on on a "PDA" Data Plan that the home screen does not display 3GBB but only displays 3G. But with Blackberry activated SIM (Home Screen Displays 3GBB) the app freezes.

 

Please use plain text.
Developer
peter_strange
Posts: 17,952
Registered: ‎07-14-2008

Re: Application developed by us only works on WIFI and FREEZES On Data network

Without knowing your code, I suggest that it is unlikely that your App actually freezes as a result of the BlackBerry changing how it connects to the wireless network.  I think it more likely that it freezes because something in your application stops working, most likely your data connection no longer gets data.  So I would recommend that you debug your app and determine what it was doing just before it froze. 

 

If it was in the middle of trying to get data, then the link and comments I posted previously should help you. 

Please use plain text.
Contributor
zahmed70
Posts: 13
Registered: ‎04-01-2011
My Carrier: Bell.ca

Re: Application developed by us only works on WIFI and FREEZES On Data network

Thanks Peter for helping us out, This is connector code, now this code works fine on non-Blackbery plan:
private String updateConnectionSuffix()
{
String connSuffix;

if (DeviceInfo.isSimulator()) {
connSuffix = ";deviceside=true";
if ( (WLANInfo.getWLANState() == WLANInfo.WLAN_STATE_CONNECTED) &&
RadioInfo.areWAFsSupported(RadioInfo.WAF_WLAN)) {
connSuffix+=";interface=wifi";
}

} else if ( (WLANInfo.getWLANState() == WLANInfo.WLAN_STATE_CONNECTED) &&
RadioInfo.areWAFsSupported(RadioInfo.WAF_WLAN)) {
connSuffix=";interface=wifi";
} else {
String uid = null;
ServiceBook sb = ServiceBook.getSB();

ServiceRecord[] records = sb.findRecordsByCid("WPTCP");


for (int i = 0; i < records.length; i++) {
if (records[i].isValid() && !records[i].isDisabled()) {

if (records[i].getUid() != null &&
records[i].getUid().length() != 0) {

if ((records[i].getCid().toLowerCase().indexOf("wptcp") != -1) &&
(records[i].getUid().toLowerCase().indexOf("wifi") == -1) &&
(records[i].getUid().toLowerCase().indexOf("mms") == -1)){
uid = records[i].getUid();
break;
}

}
}
}
if (uid != null) {
// WAP2 Connection
connSuffix = ";ConnectionUID="+uid;
} else {
connSuffix = ";deviceside=true";
}
}


return connSuffix;
}

public boolean basicAuthentication(){

try
{
_systemURL = _systemURL + updateConnectionSuffix();


s = (StreamConnection)Connector.open(_systemURL);
httpConn = (HttpConnection)s;
//while(keepGoing)
//if(keepGoing)
//{
int status = httpConn.getResponseCode();

switch (status)
{
case (HttpConnection.HTTP_OK):
//Connection is 200 OK.
//Download and process data.
keepGoing = false;
//showSearchResults();
break;


case (HttpConnection.HTTP_UNAUTHORIZED):
//Connection is 401 UnAuthorized.
//A login and password is required.


//Obtain the login information from somewhere.
//You could prompt the user for this information or
//retrieve this from elsewhere if it is saved within
//your application.
//Login information is hard coded here for brevity, but
//we ask the user if they want to log in.


UiApplication.getUiApplication().invokeAndWait(new Runnable()


{
public void run()
{
//dialogResponse = Dialog.ask
//(Dialog.D_YES_NO,"Unauthorized Access:\n Do you wish to log in?");
}
});
//the code has been modified as always need to use the credentials
//saved in the system and not have to ask if the user wants to login or not
dialogResponse = Dialog.YES;

if (dialogResponse == Dialog.YES)
{


String login = _systemUserName + ":" + _systemPassword;

//Close the connection.
s.close();


//Encode the login information in Base64 format.
byte[] encoded = Base64OutputStream.encode(login.getBytes(), 0, login.length(), false, false);


//Open a new connection.

s = (StreamConnection)Connector.open(_systemURL);
httpConn = (HttpConnection)s;

//Add the authorized header.
httpConn.setRequestProperty("Authorization", "Basic " + new String(encoded));

int responseCode = httpConn.getResponseCode();
if (responseCode == HttpConnection.HTTP_OK) {


keepGoing = false;

}
/*else {
Dialog.alert("Invalid Login Details.");
keepGoing = false;
}
*/

}
else
{
//Handle failed connection.
keepGoing = false;
}


break;


default:
//The connection failed for some other reason.
//Handle failed connection.
keepGoing = false;
break;
}
// }
//Close the connection.
s.close();

return keepGoing;

}
catch (IOException e)
{
//Handle the exception.
}

finally {
try {
s.close();
} catch (IOException e) {}


}

return keepGoing;
}
Please use plain text.
Contributor
zahmed70
Posts: 13
Registered: ‎04-01-2011
My Carrier: Bell.ca

Re: Application developed by us only works on WIFI and FREEZES On Data network

I was able to post the code in a "Quick reply" mode, as I was getting complains of an invalid HTML link

 

" ..... One more try .....

 

*********************************************************************************************************************

 

private String updateConnectionSuffix()

      {

            String connSuffix;

                                   

            if (DeviceInfo.isSimulator()) {

                connSuffix = ";deviceside=true";

                if ( (WLANInfo.getWLANState() == WLANInfo.WLAN_STATE_CONNECTED) &&

                              RadioInfo.areWAFsSupported(RadioInfo.WAF_WLAN)) {

                            connSuffix+=";interface=wifi";

                }

               

            } else if ( (WLANInfo.getWLANState() == WLANInfo.WLAN_STATE_CONNECTED) &&

                  RadioInfo.areWAFsSupported(RadioInfo.WAF_WLAN)) {

                connSuffix=";interface=wifi";

            } else {

                String uid = null;

                ServiceBook sb = ServiceBook.getSB();

               

                ServiceRecord[] records = sb.findRecordsByCid("WPTCP");

               

                

                for (int i = 0; i < records.length; i++) {

                    if (records[i].isValid() && !records[i].isDisabled()) {

                       

                        if (records[i].getUid() != null &&

                            records[i].getUid().length() != 0) {

                                                           

                            if ((records[i].getCid().toLowerCase().indexOf("wptcp") != -1) &&

                                (records[i].getUid().toLowerCase().indexOf("wifi") == -1) &&

                                (records[i].getUid().toLowerCase().indexOf("mms") == -1)){

                                uid = records[i].getUid();

                                break;

                            }

                           

                        }

                    }

                }

                if (uid != null) {

                    // WAP2 Connection

                     connSuffix = ";ConnectionUID="+uid;

                } else {

                     connSuffix = ";deviceside=true";

                }

            }

           

                             

                  return connSuffix;

      }

     

      public boolean basicAuthentication(){

           

            try

            {    

                  _systemURL = _systemURL + updateConnectionSuffix();

                 

                                   

                  s = (StreamConnection)Connector.open(_systemURL);

                  httpConn = (HttpConnection)s;          

                       //while(keepGoing)

                  //if(keepGoing)

                    //{

                        int status = httpConn.getResponseCode();

                                   

                        switch (status)

                        {

                        case (HttpConnection.HTTP_OK):

                               //Connection is 200 OK.

                               //Download and process data.

                                 keepGoing = false;

                                    //showSearchResults();

                       break;

 

                        case (HttpConnection.HTTP_UNAUTHORIZED):

                              //Connection is 401 UnAuthorized.

                             //A login and password is required.

 

                               //Obtain the login information from somewhere.

                               //You could prompt the user for this information or

                               //retrieve this from elsewhere if it is saved within

                               //your application.

                               //Login information is hard coded here for brevity, but

                               //we ask the user if they want to log in.

 

                               UiApplication.getUiApplication().invokeAndWait(new Runnable()

 

                              {

                                 public void run()

                                 {

                                    //dialogResponse = Dialog.ask

                                    //(Dialog.D_YES_NO,"Unauthorized Access:\n Do you wish to log in?");

                                 }

                              });

                                    //the code has been modified as always need to use the credentials

                                    //saved in the system and not have to ask if the user wants to login or not

                                    dialogResponse = Dialog.YES;

                                   

                               if (dialogResponse == Dialog.YES)

                               {

 

                                 String login = _systemUserName + ":" + _systemPassword;

                                 

                                  //Close the connection.

                                  s.close();

 

                                  //Encode the login information in Base64 format.

                                  byte[] encoded = Base64OutputStream.encode(login.getBytes(), 0, login.length(), false, false);

 

                                  //Open a new connection.

                                

                                  s = (StreamConnection)Connector.open(_systemURL);

                                  httpConn = (HttpConnection)s;

                                   

                                  //Add the authorized header.

                                   httpConn.setRequestProperty("Authorization", "Basic " + new String(encoded));

                                  

                                   int responseCode = httpConn.getResponseCode();

                                   if (responseCode == HttpConnection.HTTP_OK) {

 

                                         keepGoing = false;

                                  

                                   }

                                   /*else {

                                       Dialog.alert("Invalid Login Details.");

                                       keepGoing = false;

                                   }

                                   */

                                  

                                }

                                else

                                {

                                  //Handle failed connection.

                                  keepGoing = false;

                                }

 

                                break;

 

                            default:

                                //The connection failed for some other reason.

                                //Handle failed connection.

                                keepGoing = false;

                            break;

                         }

                // }

                 //Close the connection.

                 s.close();

                            

                 return keepGoing;

           

            }

            catch (IOException e)

            {

                //Handle the exception.

            }

           

            finally {

                try {

                       s.close();

                  } catch (IOException e) {}

 

               }

           

            return keepGoing;

      }

Please use plain text.
Developer
peter_strange
Posts: 17,952
Registered: ‎07-14-2008

Re: Application developed by us only works on WIFI and FREEZES On Data network

And which of the data connections supported on the BlackBerry is this using? 

 

I would be interested to know how you obtained this communication code - did you write it yourself?

 

You should review this KB article to understand the requirements for handling the various connection methods should you want to do it yourself (which is what this code is doing). 

http://supportforums.blackberry.com/t5/Java-Development/Different-ways-to-make-an-HTTP-or-socket-con...

 

And I think the code in here will give you a better feel for all the options and the coding required to detect the ones that are available and which you can use.

http://supportforums.blackberry.com/t5/Java-Development/What-Is-Network-API-alternative-for-legacy-O...

 

Finally if you want to get help on the forum, I recommend that you do what the people who are trying to help you, ask you to do.  So far, you have not actually answered any of my questions, or apparently done anything that I suggested you do.  Unless you are prepared to do what I suggest and answer questions that I ask, I can't actually help you,  Sorry. 

Please use plain text.
Contributor
zahmed70
Posts: 13
Registered: ‎04-01-2011
My Carrier: Bell.ca

Re: Application developed by us only works on WIFI and FREEZES On Data network

Thanks Peter for the Valuable info,

I did not develop the code, this code was developped by our developpers in India. Our App is basically divided into 2 parts, front-end (runs on Blackberry device) and Back-end Which runs on the Server. Our App monitors the servers.

 

Which Connection are we using, we are just accessing data over the Web (http://serveraddress) most likely going though BIS-B now that I have read some of the stuff  (links provided by you - thankyou) and also came to know about Allaince Partnership (At present We are not Allaince Partners yet). As mentioned, Our App works fine without going through BIS-B (PDA Plan)but since all the BB Devices are issued / purchased must be on a Blackberry Plan and inorder to use/access BB Messenger must have BIS configured.

I have sent the link to this page to our developers, Now do we need to be Alliance Partner? and at what level ifwe are access data and communicating with are remote servers?

 

Thanks Peter

 

Please use plain text.
Developer
peter_strange
Posts: 17,952
Registered: ‎07-14-2008

Re: Application developed by us only works on WIFI and FREEZES On Data network

As you have no doubt figured out now, the method updateConnectionSuffix() actually picks the connection method by checking to see what is currently supported on the device.  It only supports 3 methods:

a) WiFi - "'interface=wifi"

b) WAP (assuming it finds a connection suffix) - "ConnectionUID=,,,,"

c) Carrier TCP (or Direct TCP) - "deviceside=true"

 

I have a number of issues with this code, which in fact I've seen floating round here as an example of how to connect.  My issues include the fact that it does not make use of BES, which for me is the preferred method if the user has a Enterprise device.  In addition, DIrect TCP is only going to work if the user has coded the APN information in the TCP Options.  But most importantly it does not log which method has been used, so when I ask you "what method was the customer using?", you don't know and can't find out. 

 

BIS-B is not the answer to all the questions but it is certainly a good option.  If your developer is not an Alliance Partner, then they can not ask for BIS-B. However even if they are, they are not allowed to supply you with source that includes it (they can provide an application that uses it however).  But there is a 'back door into BIS-B, which I have documented here:

 

http://supportforums.blackberry.com/t5/Java-Development/Sample-HTTP-Connection-code-and-BIS-B-Access...

 

I don't know what your relationship is with your developers, but on the surface, this looks like it is their problem. 

Please use plain text.
Contributor
zahmed70
Posts: 13
Registered: ‎04-01-2011
My Carrier: Bell.ca

Re: Application developed by us only works on WIFI and FREEZES On Data network

Peter I don't know how to Thank you or do something to repay you, people like you are a "Rare Commodity".

If this app works out, I may have to repay you somehow.  As you probably realized by now that you are dealing with "lost newbies", this is our first project developing app for Blackberry and thought that it will be easy.... Oh well.

 

I had a chance to talk to Bell Mobility (my service providor) and go it confirmed that everything on BB plan goes

through BIS-B.

As mentioned, I did register with Alliance partners but after that ..Nothing. I don't know how many calls I made and emails I sent to RIM to get through but all ran into walls and dead ends.

So how do I associate our app which is now released, with Alliance Program? as there is no contact info or email address.

and your suggestions were sent to our developpers.... Hoping that they will fix the issue and  .... you are right there is something very wrong, .... Lack of planning and know how about BB.

 

Thanks again

Zeeshan

Please use plain text.