Welcome!

Welcome to the Official BlackBerry Support Community Forums. This is your resource to discuss support topics with your peers, and learn from each other. New to the forum? Please visit the ‘Getting Started’ link below.
inside custom component

Java Development

Reply
Regular Contributor
gunar_dev
Posts: 57
Registered: ‎09-22-2010

Re: check network status

Absolutelly! Thanks for the valuable comments ...

 

This is my way of getting the preffered connection types. I think it matches with your (b) option ... I wasn't aware of the limitations that (a) gives.

 

private int[] getPreferredTransportTypes() {
		int[] availableTransports = TransportInfo.getAvailableTransportTypes();
		Vector temp = new Vector();
		if (isTransportTypeSupported(TransportInfo.TRANSPORT_MDS, availableTransports)) {
			temp.addElement(new Integer(TransportInfo.TRANSPORT_MDS));
		}
		if (isTransportTypeSupported(TransportInfo.TRANSPORT_TCP_WIFI, availableTransports)) {
			temp.addElement(new Integer(TransportInfo.TRANSPORT_TCP_WIFI));
		}
		if (isTransportTypeSupported(TransportInfo.TRANSPORT_BIS_B, availableTransports)) {
			temp.addElement(new Integer(TransportInfo.TRANSPORT_BIS_B));
		}
		if (isTransportTypeSupported(TransportInfo.TRANSPORT_WAP2, availableTransports)) {
			temp.addElement(new Integer(TransportInfo.TRANSPORT_WAP2));
		}
		if (isTransportTypeSupported(TransportInfo.TRANSPORT_TCP_CELLULAR, availableTransports)) {
			temp.addElement(new Integer(TransportInfo.TRANSPORT_TCP_CELLULAR));
		}
		int size = temp.size();
		int[] result = new int[size];
		for (int i = 0; i < size; i++) {
			result[i] = ((Integer) temp.elementAt(i)).intValue();
		}
		return result;
	}

	public boolean isTransportTypeSupported(int type, int[] availableTransports) {
		int size = availableTransports.length;
		for (int i = 0; i < size; i++) {
			if (availableTransports[i] == type) {
				return true;
			}
		}
		return false;
	}

 

The strangest thing is that I noticed that when using BIS, then 

TransportInfo.isTransportTypeAvailable(TransportInfo.TRANSPORT_BIS_B)

 returns false, even if that connection is available - I could browse the internet using native browser.

 

So far I didn't experience any issues with above code ...

Please use plain text.
Developer
peter_strange
Posts: 17,722
Registered: ‎07-14-2008

Re: check network status

Remember that to get BIS-B you need to have a parameter, that may be why it is not available. 

Please use plain text.