⭐ 欢迎来到虫虫下载站! | 📦 资源下载 📁 资源专辑 ℹ️ 关于我们
⭐ 虫虫下载站

📄 transportutils.java

📁 In the last three articles, I’ve been walking you through the creation of an end-to-end BlackBerry a
💻 JAVA
字号:
package KnowledgeBase;

import java.io.*;
import java.lang.*;
import net.rim.device.api.system.*;
import net.rim.blackberry.api.mail.*;
/**
 * Some static utility methods which may be useful for applications which 
 * make HTTP connections. 
 * @author Adam Rogers, Wireless Solutions Archetect, Research In Motion
 * @version %I%, %G%
 */
public class TransportUtils{

    
    
    /**
     * true if the device is able to send and receive <bold>data</bold>
     * @return   <code>true</code> if the handheld can make http connections;
     *           <code>false</code> otherwise.
     */
    public static boolean isInCoverage(){
        int service = RadioInfo.getNetworkService();
        if ((service & RadioInfo.NETWORK_SERVICE_DATA) == RadioInfo.NETWORK_SERVICE_DATA){
            int level = RadioInfo.getSignalLevel();
            if (level != RadioInfo.LEVEL_NO_COVERAGE){
                return true;
            }
        }
        return false;
    }    
    
     /**
     * true if the device is on the iDEN network.  Otherwise false
     * @return   <code>true</code> if the handheld is iDEN based
     *           <code>false</code> otherwise.
     */
    public static boolean isDevicesideRequired(){
        int service = RadioInfo.getNetworkType();
        if (service == RadioInfo.NETWORK_IDEN) {
                return true;
        }
        return false;
    } 
    
    public static String createRequestString(final String[] keys, final String[] values) {
        
        StringBuffer requestContents = new StringBuffer("");
           if (keys != null) {               
                for (int i = 0; i < keys.length; i++) {
                    requestContents.append(keys[i] + "=" +  values[i] + "&");              
                }
           }
           // Terminate the request with a valid sequence.
           requestContents.append("0=0\r\n");    
           
           return requestContents.toString();
    }     
}

⌨️ 快捷键说明

复制代码 Ctrl + C
搜索代码 Ctrl + F
全屏模式 F11
切换主题 Ctrl + Shift + D
显示快捷键 ?
增大字号 Ctrl + =
减小字号 Ctrl + -