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.

inside custom component

Java Development

Reply
Regular Contributor
Posts: 57
Registered: ‎09-22-2010
My Device: Not Specified

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 ...

Highlighted
Developer
Posts: 19,636
Registered: ‎07-14-2008
My Device: Not Specified

Re: check network status

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