如何使用qnx.net.NetworkManager空气SDK来检测网络中的黑莓10开发阿尔法模拟器 [英] How to detect network in Blackberry 10 Dev Alpha Simulator using qnx.net.NetworkManager on Air SDK

查看:127
本文介绍了如何使用qnx.net.NetworkManager空气SDK来检测网络中的黑莓10开发阿尔法模拟器的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我想用这个code检测模拟器的互联网连接

I'm trying to detect internet connection of the simulator using this code

if (
    NetworkManager.networkManager.isConnected(NetworkType.WIFI) ||
    NetworkManager.networkManager.isConnected(NetworkType.CELLULAR)
) {
    //we have connection!!
    doSomething();
} else {
    //no connection =(
    showError();
}

不过,这始终返回false。看来这个模拟器使用另一种不NETWORKTYPE常量识别网络。我认为,出现这种情况是因为,VMware使得通过魔法连接成为可能。

However, this always returns false. It seems that the simulator uses another kind of network not identified by NetworkType constants. I think this happens because VMWare makes connection possible through black magic.

所以,我不知道我是否应该坚持这一code和希望它会在一个真实的设备工作使用WiFi或蜂窝网络,还是应该找到我所需要的另一种方法。

So i am not sure if I should stick to this code and hope it will work in a real device using WiFi or Cellular network, or should find another approach for what I need.

我也试着这样做(没有传递参数)

I've also tried doing this (passing no parameters)

NetworkManager.networkManager.isConnected()

但它总是尽管如果我有Internet连接或没有在我的电脑返回true。我认为VMware是再次曳我。

but it will always return true despite if I have internet connection or not in my PC. I think VMWare is trolling me again.

所以,对我应该怎么做这更好的结果了真实设备什么建议?

So, any advice on how should I do this for better results in a real device?

推荐答案

好了,只是为了更新。我终于得到了一个BBZ10,并有机会尝试这种code。看上去像      NetworkManager.networkManager.isConnected(NetworkType.WIFI) 和      NetworkManager.networkManager.isConnected(NetworkType.CELLULAR) 将工作预计他们的样子,就算仿真器将无法真正效仿他们的funcionality。

Well, just to update. I finally got a BBZ10, and had a chance to try this code. It seems that NetworkManager.networkManager.isConnected(NetworkType.WIFI) and NetworkManager.networkManager.isConnected(NetworkType.CELLULAR) will work the way they are expected, even if the emulator can't really emulate their funcionality.

所以,如果你真的需要这个功能,继续前进,试试这个,它会真正发挥作用,一旦部署。

So, if you really need this functionality, go ahead and try this, it WILL really work once deployed.

这篇关于如何使用qnx.net.NetworkManager空气SDK来检测网络中的黑莓10开发阿尔法模拟器的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆