测试设备上的 http 连接
你好,开发一个 bb 应用程序,我需要建立 http 连接来获取文件、图像等。 在模拟器中一切正常,但在设备中则不行。 我买了一部黑莓手机,但我想在没有 SIM 卡的情况下测试我的应用程序。
我需要如何设置我的设备?我该如何编写我的网址?
我只有一个带 wifi 的 bb 设备
谢谢大家 :)
Sergio
Hallo, developing a bb app I need to make http connections to get files, images etc.
In simulator all works, but not in device.
I bought a BlackBerry but I want to test my app without a sim then without a bes.
How do I need to set my device? and how do I have to compose my url?
I just have a bb device with wifi available
Thanks all :)
Sergio
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(2)
正如这个重复问题的回答...
这是一个对我来说很难!
正如 Mark 所说,您必须在 url 中添加一些参数才能使其在设备上运行。您不应该手动执行此操作,而应使用 ConnectionFactory。
正如您可能认为这只会使其工作,但事实并非如此!
真正的问题是 url 没有被改变,因为它里面有 ;interface=wifi;deviceside=true (在我的例子中)。根据接受您的请求的网络服务器,这可能会破坏代码。
我尝试过并且有效的解决方案是尝试发生像这样的假参数,
这将作为网络服务器的标准参数,但您的设备将使用它来驱动您的连接。
在模拟器上,这项工作不需要额外的代码,因为它后面有一个 BIS 服务器供您使用。在设备上(如我的情况)没有,因为我使用的是未注册且没有 SIM 卡(仅 wifi)的开发设备。
另一点是 HttpConnection 类不处理 HTTP 302 重定向,如果您得到一个,则必须手动处理它。
As answered for this duplicate question...
This was a tough one for me!
As Mark said you have to put some parameters in the url to make it work on the device. You shouldn't do it by hand but use the ConnectionFactory instead.
As you may thing this would just make it work but it doesn't!
The real problem is that not the url has been altered because it has ;interface=wifi;deviceside=true in it (in my case). Depending on the webserver accepting your request this could broke the code.
A solution I tried and that works is try to happend a fake parameter like
This will result as a standard parameter for the webserver but your device would use it to driver your connection.
On the simulator this work without this extra code because behind it there is a BIS server for you. On the device (as in my case) there isn't because I'm using a development device unregistered and without SIM (just wifi).
Another point is that the HttpConnection class doesn't handle HTTP 302 Redirect and if you get one you have to handle it manually.
使用设备时,尝试将“;interface=wifi”附加到 URL 上(而不是“;deviceside=true”)。这将强制建立 Wi-Fi 连接(假设设备有 Wi-Fi)。
Try appending ";interface=wifi" onto the URL when using a device (instead of ";deviceside=true"). This will force a Wi-Fi connection (assuming the device has Wi-Fi).