HttpConnection not working in real device -Blackberry

前端 未结 1 1435
北海茫月
北海茫月 2021-01-16 10:40

this is my code

public String Serverconnection(String url) {

    String line = \"\";

    if (DeviceInfo.isSimul         


        
1条回答
  •  孤城傲影
    2021-01-16 11:32

    refer to the knowledge center article "Different ways to make an HTTP or socket connection"

    Append the connection string to your url.Then try

    private static String getConnectionString(){
    String connectionString="";
    if(WLANInfo.getWLANState()==WLANInfo.WLAN_STATE_CONNECTED){
        connectionString="?;interface=wifi";
    }
    
    else if((CoverageInfo.getCoverageStatus() & CoverageInfo.COVERAGE_MDS) == CoverageInfo.COVERAGE_MDS){
         connectionString = "?;&deviceside=false";
    }
    else if((CoverageInfo.getCoverageStatus() & CoverageInfo.COVERAGE_DIRECT)==CoverageInfo.COVERAGE_DIRECT){
        String carrierUid=getCarrierBIBSUid();
        if(carrierUid == null) {
            connectionString = "?;deviceside=true";
        }
        else{
            connectionString = "?;deviceside=false?;connectionUID="+carrierUid + "?;ConnectionType=mds-public";
        }               
    }
    else if(CoverageInfo.getCoverageStatus() == CoverageInfo.COVERAGE_NONE) {          
            }
        return connectionString;
    }
    

    Edit : -

    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;
    }
    

    0 讨论(0)
提交回复
热议问题