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
Developer
simon_hain
Posts: 16,282
Registered: ‎07-29-2008
My Device: Z10 LE, Z30, Passport

Re: BIS Not Working

http://www.blackberry.com/developers/docs/7.1.0api/net/rim/device/api/io/transport/options/BisBOptio...
----------------------------------------------------------
feel free to press the like button on the right side to thank the user that helped you.
please mark posts as solved if you found a solution.
@SimonHain on twitter
Contributor
ArulRaja
Posts: 18
Registered: ‎04-10-2013
My Device: 9900

Re: BIS Not Working

Thanks for your response

i have enabled push test service in my app and given the following code

 

private void execute(){
String response;
private ConnectionFactory _factory;
_factory = new ConnectionFactory();
_factory.setAttemptsLimit(2);
_factory.setPreferredTransportTypes(new int[] { TransportInfo.TRANSPORT_BIS_B,
TransportInfo.TRANSPORT_TCP_WIFI, TransportInfo.TRANSPORT_WAP,
TransportInfo.TRANSPORT_WAP2, TransportInfo.TRANSPORT_MDS,
TransportInfo.TRANSPORT_TCP_CELLULAR });
try {
HttpConnection conn = (HttpConnection) _factory.getConnection(
url + getConnectionString()).getConnection();
if (conn != null && conn.getResponseMessage().equals("OK")) {
response = new String(IOUtilities.streamToBytes(conn.openInputStream()));
} else if (conn != null) {
response = new String(IOUtilities.streamToBytes(conn.openInputStream()));
}
conn.close();
} catch (Exception e) {
e.printStackTrace();
}
}

 

private String getConnectionString() {
String connectionString = null;

// Simulator behavior is controlled by the USE_MDS_IN_SIMULATOR
// variable.
if (DeviceInfo.isSimulator()) {
System.out.println("Device is a simulator and USE_MDS_IN_SIMULATOR is false");
connectionString = ";deviceside=true";
}

// Wifi is the preferred transmission method
else if (WLANInfo.getWLANState() == WLANInfo.WLAN_STATE_CONNECTED) {
System.out.println("Device is connected via Wifi.");
connectionString = ";interface=wifi";
}

// Is the carrier network the only way to connect?
else if ((CoverageInfo.getCoverageStatus() & CoverageInfo.COVERAGE_DIRECT) == CoverageInfo.COVERAGE_DIRECT) {
System.out.println("Carrier coverage.");

String carrierUid = getCarrierBIBSUid();
if (carrierUid == null) {
// Has carrier coverage, but not BIBS. So use the carrier's TCP
// network
System.out.println("No Uid");
connectionString = ";deviceside=true";
} else {
// otherwise, use the Uid to construct a valid carrier BIBS
// request
Utilities.showAlert(carrierUid);
System.out.println("uid is: " + carrierUid);
connectionString = ";deviceside=false;connectionUID=" + carrierUid;ConnectionType=mds - public";
}
}

// Check for an MDS connection instead (BlackBerry Enterprise Server)
else if ((CoverageInfo.getCoverageStatus() & CoverageInfo.COVERAGE_MDS) == CoverageInfo.COVERAGE_MDS) {
System.out.println("MDS coverage found");
connectionString = ";deviceside=false";
}

// If there is no connection available abort to avoid bugging the user
// unnecssarily.
else if (CoverageInfo.getCoverageStatus() == CoverageInfo.COVERAGE_NONE) {
System.out.println("There is no available connection.");
}

// In theory, all bases are covered so this shouldn't be reachable.
else {
System.out.println("no other options found, assuming device.");
connectionString = ";deviceside=true";
}

return connectionString;
}

 

/**
* Looks through the phone's service book for a carrier provided BIBS
* network
*
* @return The uid used to connect to that network.
*/


private static String getCarrierBIBSUid() {
ServiceRecord[] records = ServiceBook.getSB().getRecords();
int currentRecord;

for (currentRecord = 0; currentRecord < records.length; currentRecord++) {
if (records[currentRecord].getCid().toLowerCase().equals("ippp")) {
if (records[currentRecord].getName().toLowerCase().indexOf("bibs") >= 0) {
return records[currentRecord].getUid();
}
}
}

return null;
}

 

*  In my device options - > Device ->Advanced System Setting -> Sevice Book  - >

i dont have this option IPPP for BIBS

 

bis not working with the code


plz let me know if anything has to be changed in the above code to make bis to work

 

Developer
peter_strange
Posts: 19,610
Registered: ‎07-14-2008
My Device: Not Specified

Re: BIS Not Working

If you don't have the service record, this suggests you do not have a BlackBerry plan that includes BIS.  I suggest you confirm with your carrier. 

Contributor
ArulRaja
Posts: 18
Registered: ‎04-10-2013
My Device: 9900

Re: BIS Not Working


Thanks for your response

 

i am using IDEA mobile service india i checked with carrier, i am using blackberry internet service only.

 

my amount is not reducing while am browsing.but when am using the application the amount is going...

 

i find IPPP for BIS-B[IPPP] in my service book settings


what can i do now .......... plz help me

 

Developer
peter_strange
Posts: 19,610
Registered: ‎07-14-2008
My Device: Not Specified

Re: BIS Not Working

OK it seems that now you can find the service record for BIS-B, nw and didn't before. 

 

I should have looked at your code earlier - there is a problem in it in my opinion.  You either use ConnectionFactory, or you try to use your code that sets the connection string.  You appear to be using both which I suspect will confuse the issue.

 

So please change this:

 

HttpConnection conn = (HttpConnection) _factory.getConnection( url + getConnectionString()).getConnection();

 

to this:

 

HttpConnection conn = (HttpConnection) _factory.getConnection(url).getConnection();

 

However this code is in my opinion, not the best option.  You should just get the ConnectionDescriptor, and make sure it is null before trying to get a connection.  And I would check the descriptor to find out which connection method it has actually given you. 

 

So something like is better I think:

ConnectionDescriptor cd = _factory.getConnection(url);

if ( cd != null ) {

    HttpConnection conn = (HttpConnection) cd.getConnection();

 

I would review other pats of your connection code, it looks like you try very hard to write the fewest lines of code and in my experience, that will mask problems. 

 

And the other thing you need to be careful of is character encoding.  Most servers standard character encoding is UTF-8, but this is not the default on the BlackBerry. 

 

Finally this code will not actually give you anything:

 

} catch (Exception e) { e.printStackTrace(); }

 

You do NOT get a stack trace with an Exception.  And in fact, the stack trace is not that useful here anyway.  You should make sure that your know the exception and the messages associated with it.  So log

e.toString()

Developer
simon_hain
Posts: 16,282
Registered: ‎07-29-2008
My Device: Z10 LE, Z30, Passport

Re: BIS Not Working

when using connection factory with bis-b note that you have to set the connection parameter manually using http://www.blackberry.com/developers/docs/7.1.0api/net/rim/device/api/io/transport/options/BisBOptio...
----------------------------------------------------------
feel free to press the like button on the right side to thank the user that helped you.
please mark posts as solved if you found a solution.
@SimonHain on twitter
Developer
peter_strange
Posts: 19,610
Registered: ‎07-14-2008
My Device: Not Specified

Re: BIS Not Working

Contributor
ArulRaja
Posts: 18
Registered: ‎04-10-2013
My Device: 9900

Re: BIS Not Working

Thank u for your response .

 

how to set the BisBOptions in setConnectionType(String connectionType).

 

could u plz say me.what should i give for connectiontype?


can i get the sample code of it plz?

Developer
simon_hain
Posts: 16,282
Registered: ‎07-29-2008
My Device: Z10 LE, Z30, Passport

Re: BIS Not Working

it is the "secret" connection string for BIS-B, you can get it from the official bis push sample code, or find it on the web or...
in this forum it is not allowed to post it as its usage is not public.
----------------------------------------------------------
feel free to press the like button on the right side to thank the user that helped you.
please mark posts as solved if you found a solution.
@SimonHain on twitter
Contributor
ArulRaja
Posts: 18
Registered: ‎04-10-2013
My Device: 9900

Re: BIS Not Working

I find the "secret" connection string for BIS-B.

Now BIS is work fine

 

    Thanks for your response