开发者

Multicast Support in Android 2.2?

Does the Android 2.2 media framework support IG开发者_JAVA技巧MP/Multicast? If yes, can anyone guide how we can do that?


It is quite simple:

  1. Inform the wifimanager that your app need to receive multicast:

    WifiManager wifi = (WifiManager)getSystemService( Context.WIFI_SERVICE );
    MulticastLock mcLock = wifi.createMulticastLock("mylock");
    mcLock.acquire();
    
  2. Create the socket:

    InetAddress group = InetAddress.getByName(MULTICAST_ADDRESS);
    MulticastSocket s = new MulticastSocket(MULTICAST_PORT);
    s.joinGroup(group);
    


It appears that Multicast support in Android is not as solid as some of use might hope. See http://codeisland.org/2012/udp-multicast-on-android/

Ie whether it actually works out or may be device dependent. It is not working on my Nexus5.

https://code.google.com/p/android/issues/detail?id=51195

0

上一篇:

下一篇:

精彩评论

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

最新问答

问答排行榜