BlackBerry - 使用 WAP2 的连接问题
我正在尝试建立与以下网址的连接:
问题是,当我尝试使用 WAP2 连接到上述网址时,我得到的连接为 null ,另一方面,我能够建立连接并当我在 WIFI 上建立连接时得到正确的响应。
附加:
“;ConnectionUID=WAP2Trans”到上面的网址不起作用。(将连接设置为空)
而
附加
“;interface=wifi”到上面的网址有效。
我获取 ConnectionUID 的逻辑是:
ServiceBook sb = ServiceBook.getSB();
net.rim.device.api.servicebook.ServiceRecord[] records =
sb.findRecordsByCid("WPTCP");
String uid = null;
/*System.out.println("*****************Records are :" + records);
System.out.println("*****************Records length :" + ecords.length);*/
for(int i=0; i < records.length; i++) {
if (records[i].isValid() && !records[i].isDisabled()) {
if (records[i].getUid() != null && records[i].getUid().length() != 0) {
if ((records[i].getCid().toLowerCase().indexOf("wptcp") != -1) &&
records[i].getUid().toLowerCase().indexOf("wap2") !=- 1 &&
(records[i].getUid().toLowerCase().indexOf("wifi") == -1) &&
(records[i].getUid().toLowerCase().indexOf("mms") == -1)) {
uid = records[i].getUid();
break;
}
}
}
}
if (uid != null) {
url = url +";ConnectionUID=" + uid;
}
I am trying to establish connection to following url :
The problem is that when i am trying to make an connection to above url using WAP2 i am getting connection as null , on the other hand i am able to establish connection and getting correct response when i am making connection on WIFI.
appending :
";ConnectionUID=WAP2Trans" to above url doesn't work.(getting connection as null)
while
appending
";interface=wifi" to above url works.
My logic for getting ConnectionUID is :
ServiceBook sb = ServiceBook.getSB();
net.rim.device.api.servicebook.ServiceRecord[] records =
sb.findRecordsByCid("WPTCP");
String uid = null;
/*System.out.println("*****************Records are :" + records);
System.out.println("*****************Records length :" + ecords.length);*/
for(int i=0; i < records.length; i++) {
if (records[i].isValid() && !records[i].isDisabled()) {
if (records[i].getUid() != null && records[i].getUid().length() != 0) {
if ((records[i].getCid().toLowerCase().indexOf("wptcp") != -1) &&
records[i].getUid().toLowerCase().indexOf("wap2") !=- 1 &&
(records[i].getUid().toLowerCase().indexOf("wifi") == -1) &&
(records[i].getUid().toLowerCase().indexOf("mms") == -1)) {
uid = records[i].getUid();
break;
}
}
}
}
if (uid != null) {
url = url +";ConnectionUID=" + uid;
}
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(3)
试试这个
try this
你不应该尝试
而不是
检查 -1 而不是 =- 1
让我知道这是否有效
Shouldn't you try
instead of
check the -1 and not =- 1
Let me know if this works
我想是因为这个条件:
(records[i].getCid().toLowerCase().indexOf("wptcp") != -1)
您之前通过 WPTCP 进行过滤:
记录 = sb.findRecordsByCid("WPTCP");
所以我猜循环中的所有记录都会有 WPTCP 的 Cid
I think it is because this condition:
(records[i].getCid().toLowerCase().indexOf("wptcp") != -1)
You are previously filtering by WPTCP:
records = sb.findRecordsByCid("WPTCP");
so I guess all records in the loop will have the Cid to WPTCP