Blackberry wifi http connection

痞子三分冷 提交于 2019-12-19 12:49:10

问题


I am building a blackberry application takes input from user then send input to a server and displays the xml returned from server.

The problem is, while application works fine on simulator it doesn't show results all the time on real device. Sometimes it is working but usually it's not. I am using wifi connection on device. The code is:

Connector.open(url + ";interface=wifi");

I am not using wifi on simulator. I just delete the 'interface=wifi' part and it runs using mds.

When input taken, a class extending Thread starts. It opens the connection and initializes variables. I take the inputstream from class and parse the xml. The device is a Blackberry 9700.I read something about connection timeout but i am not sure where problem is.

Edit: Found a simple way to connect. Here is the code for a GET request:

ConnectionFactory cf = new ConnectionFactory();
ConnectionDescriptor cd = cf.getConnection("YourUrl");
httpConnector = (HttpConnection) cd.getConnection();
httpConnector.setRequestMethod(HttpConnection.GET);

回答1:


Maybe this might help: http://www.localytics.com/blog/2009/how-to-reliably-establish-a-network-connection-on-any-blackberry-device/

The idea in that blog post is to check if WiFi is enabled, and in that case use that for connection string, and so on for various connection types.



来源:https://stackoverflow.com/questions/6382175/blackberry-wifi-http-connection

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!