Posted by: iBNuX | May 2, 2010

Auto Check Connection for Blackberry

script ini akan menentukan jalur secara otomatis dalam melakukan koneksi http/tcp.
apakah melalui Wifi, MDS/BES dan directTCP.

simpan dengan nama

import net.rim.device.api.system.CoverageInfo;
import net.rim.device.api.system.DeviceInfo;
import net.rim.device.api.system.WLANInfo;

public final class ConnString {
    public static String getConnectionString()
        String st = "";
	    //The Device is a simultaor --> TCP
	        if (DeviceInfo.isSimulator()){
	            return "";
        	}else if (WLANInfo.getWLANState() == WLANInfo.WLAN_STATE_CONNECTED) {
	            st =  ";interface=wifi";
	        } else if ((CoverageInfo.getCoverageStatus() & CoverageInfo.COVERAGE_MDS) == CoverageInfo.COVERAGE_MDS){
	            st = ";deviceside=false";// use the clients blackberry enterprise server
	            st = ";deviceside=true";// let the phone do the work if it can
        }catch(Exception e){
	            return st + ";ConnectionTimeout=45000";


gunakan tiap akan melakukan koneksi pada url

HttpConnection connection = null;
connection = (HttpConnection)"http://ibnux.netapa?ini=itu"+
ConnString.getConnectionString(), Connector.READ, true);

Leave a Reply

Fill in your details below or click an icon to log in: Logo

You are commenting using your account. Log Out /  Change )

Google photo

You are commenting using your Google account. Log Out /  Change )

Twitter picture

You are commenting using your Twitter account. Log Out /  Change )

Facebook photo

You are commenting using your Facebook account. Log Out /  Change )

Connecting to %s


%d bloggers like this: