Search This Blog

Saturday, 28 April 2012

How to make your app able to use network BES,Direct TCP or Wifi

Hello friends,
Here is the code to make your app able to communicate to remote server with the available service no matter if it is BES ,Direct TCP,or Wifi...
                        ConnectionParameter = ";interface=wifi";
                    }else if((CoverageInfo.getCoverageStatus() & CoverageInfo.COVERAGE_DIRECT) == CoverageInfo.COVERAGE_DIRECT) {
                        String carrierUid = getCarrierBIBSUid();
                        if(carrierUid == null)
                            // Has carrier coverage, but not BIBS.  So use the carrier's TCP network
//                            logMessage("No Uid");
                            ConnectionParameter = ";deviceside=true";
                            // otherwise, use the Uid to construct a valid carrier BIBS request
//                            logMessage("uid is: " + carrierUid);
                            ConnectionParameter = ";deviceside=false;connectionUID="+carrierUid + ";ConnectionType=mds-public";
                    }else if((CoverageInfo.getCoverageStatus() & CoverageInfo.COVERAGE_MDS) == CoverageInfo.COVERAGE_MDS)
//                        logMessage("MDS coverage found");
                         ConnectionParameter = ";deviceside=false";
Now, just pass this ConnectionParameter String variable with your url for ex:

The app will detect which network type is available and pass the parameters as required for the available network type.

The following is the function for "getCarrierBIBSUid()"

 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;

No comments:

Post a Comment