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:
Inform the wifimanager that your app need to receive multicast:
WifiManager wifi = (WifiManager)getSystemService( Context.WIFI_SERVICE ); MulticastLock mcLock = wifi.createMulticastLock("mylock"); mcLock.acquire();
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
精彩评论