Note that there are some explanatory texts on larger screens.

plurals
  1. POGetting an active connection on a Blackberry
    text
    copied!<p>I get the connection parameters for my HTTP call using the code that follows below.</p> <p>It works on my test phones and emulators. However for some people (possibly just 9700 users, but I can't guarantee it) it causes <code>"Failed to transmit"</code> errors even when they have an otherwise working 3G/wifi connection. </p> <p>What am I doing wrong?</p> <pre><code> private String getConnectionParameters() { String strCP = null; int coverageStatus = CoverageInfo.getCoverageStatus(); if((coverageStatus &amp; CoverageInfo.COVERAGE_DIRECT) == CoverageInfo.COVERAGE_DIRECT) { // Carrier coverage String carrierUid = getCarrierBIBSUid(); if(carrierUid == null) { String wap2 = getWAP2ServiceRecord(); if (wap2 != null) { // Try using WAP2 strCP = ";deviceside=false;connectionUID="+wap2; } else { // Has carrier coverage, but not BIBS or WAP2. So use the carrier's TCP network strCP = ";deviceside=true"; } } else { // otherwise, use the Uid to construct a valid carrier BIBS request strCP = ";deviceside=false;connectionUID="+carrierUid + ";ConnectionType=mds-public"; } } else if((coverageStatus &amp; CoverageInfo.COVERAGE_MDS) == CoverageInfo.COVERAGE_MDS) { // MDS coverage found strCP = ";deviceside=false"; } else if((WLANInfo.getWLANState() == WLANInfo.WLAN_STATE_CONNECTED) &amp;&amp; RadioInfo.areWAFsSupported(RadioInfo.WAF_WLAN)) { // Device is connected via Wifi strCP = ";interface=wifi"; } else if(coverageStatus == CoverageInfo.COVERAGE_NONE) { // There is no available connection strCP = ""; } else { // no other options found, assuming device strCP = ";deviceside=true"; } return strCP; } private String getCarrierBIBSUid() { ServiceRecord[] records = ServiceBook.getSB().getRecords(); for(int i = 0; i &lt; records.length; i++) { if(records[i].getCid().toLowerCase().equals("ippp")) { if(records[i].getName().toLowerCase().indexOf("bibs") &gt;= 0) { return records[i].getUid(); } } } return null; } private String getWAP2ServiceRecord() { ServiceBook sb = ServiceBook.getSB(); ServiceRecord[] records = sb.getRecords(); for (int i = 0; i &lt; records.length; i++) { String cid = records[i].getCid().toLowerCase(); String uid = records[i].getUid().toLowerCase(); if ((cid.indexOf("wptcp") != -1) &amp;&amp; (uid.indexOf("wifi") == -1) &amp;&amp; (uid.indexOf("mms") == -1)) { return records[i].getUid(); } } return null; } </code></pre>
 

Querying!

 
Guidance

SQuiL has stopped working due to an internal error.

If you are curious you may find further information in the browser console, which is accessible through the devtools (F12).

Reload