02-28-2012 11:57 AM
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 ...
02-28-2012 12:58 PM
Remember that to get BIS-B you need to have a parameter, that may be why it is not available.