开发者

BlackBerry - Connection problem using WAP2

开发者 https://www.devze.com 2022-12-18 08:32 出处:网络
I am trying to establish connection tofollowing url : \" http://local.yahooapis.com/LocalSearchService/V3/localSearch?appid=0KOmkJ7V34Hvfo6oPV4YJaKmTz69b_UMMhOyBex5v24Gnyr3t4lrN26HBjwbfT.khg--&qu

I am trying to establish connection to following url :

" http://local.yahooapis.com/LocalSearchService/V3/localSearch?appid=0KOmkJ7V34Hvfo6oPV4YJaKmTz69b_UMMhOyBex5v24Gnyr3t4lrN26HBjwbfT.khg--&query=pepsi&latitude=37.79581&longitude=-122.38008&results=5"

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开发者_JAVA技巧 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;
   }


try this

url = url +";deviceside=true;ConnectionUID=" +uid;


Shouldn't you try

records[i].getUid().toLowerCase().indexOf("wap2") != -1 &&

instead of

records[i].getUid().toLowerCase().indexOf("wap2") !=- 1 &&

check the -1 and not =- 1

Let me know if this works


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

0

精彩评论

暂无评论...
验证码 换一张
取 消