如何选择网关?

冰泠 2011-08-16 12:00:30
public final class HttpUtils {

public final static String connectionString = ";deviceside=true;WAPGatewayIP=10.0.0.172;WAPGatewayAPN=cmwap";//移动网关
public final static String uni_connectionString = ";deviceside=true;WAPGatewayIP=10.0.0.172;WAPGatewayAPN=uniwap";//联通网关
private static final Connection IOException = null;

public static Connection getConnection(String url)throws IOException{


return Connector.open(url + (DeviceInfo.isSimulator() ? "" : connectionString));
//这里返回一个联通或者移动的网关 ,我都能上网,现在我要做的是:判断这两个网关,在使用移动手机号码时他使用移动网关,在使用联通号码时 他自动选择联通网关, 我做了很久, 用了几种方法 还是没能实现 {鄙人愚钝!!}
请教高手 指点

}
...全文
372 4 打赏 收藏 转发到动态 举报
写回复
用AI写文章
4 条回复
切换为时间正序
请发表友善的回复…
发表回复
潮灬汐 2011-09-29
  • 打赏
  • 举报
回复
如果不是没办法,劝楼主别做黑莓开发,至少现在别做呢
shupo 2011-09-29
  • 打赏
  • 举报
回复
学习了
冰泠 2011-08-16
  • 打赏
  • 举报
回复
public static Connection getConnection(String url) throws IOException {

int[] preferredTransportTypes = {TransportInfo.TRANSPORT_MDS,TransportInfo.TRANSPORT_WAP2};

ConnectionDescriptor connectionDescriptor = factory.getConnection(url);
if (connectionDescriptor != null) {

int transportUsed = connectionDescriptor.getTransportDescriptor().getTransportType();

HttpConnection httpConnection = (HttpConnection) connectionDescriptor.getConnection();

return httpConnection;
}


return null;
}

return null;
}

我这样写 报错 :::java lang Illegal Argument Exception: Parameter out of range
而在连接方式列表里面只写一个连接方式,又给我一个 空指针 报错

崩溃了!!!!
儿大不由爷 2011-08-16
  • 打赏
  • 举报
回复
首先手机号码是不一定能得到,所以不能用手机号码来判断。
联通的和移动的那个网管的IP地址和端口都是相同的吧,不需要区分的。

1,146

社区成员

发帖
与我相关
我的任务
社区描述
探讨BlackBerry智能手机开发相关的技术、软件、产品等话题。
社区管理员
  • BlackBerry
加入社区
  • 近7日
  • 近30日
  • 至今
社区公告
暂无公告

试试用AI创作助手写篇文章吧