0

我正在尝试使用 jmdns 发现一些移动设备。只要我有 wifi 或 3G 连接,就可以发现这些设备。从那以后,我使用4G连接,它说没有检测到任何设备。

ConnectivityManager conMgr = (ConnectivityManager) getSystemService (Context.CONNECTIVITY_SERVICE);
if ( conMgr.getNetworkInfo(ConnectivityManager.TYPE_MOBILE).getState() == NetworkInfo.State.CONNECTED 
                || conMgr.getNetworkInfo(ConnectivityManager.TYPE_WIFI).getState() == NetworkInfo.State.CONNECTED ) {}

我是否必须设置另一个条件才能启用 4G 连接?以编程方式,4G 和 3G 之间最显着的区别是什么?

4

1 回答 1

0

I'm quite surprised it works on 3g.

Bonjour/Zeroconf uses mDNS to discover other devices IP addresses. It uses multicast UDP to announce itself to others. I'm quite sure this does not work on 3g networks as they use NAT to separate users from each other and to prevent devices on internet connecting to them (inbound connections - internet to 3g device). Reads this guys testing of multicast UDP on 3g: http://sourceforge.net/projects/open-dis/forums/forum/683284/topic/4058262

Update

For detecting the network on current 4g devices you should check the ConnectivityManager.TYPE_WIMAX.

于 2011-10-11T19:05:59.980 回答