}).start();
}
}
private InterfaceAddress getPreferredInetAddress(String prefix) {
InterfaceAddress selectedInterfaceAddress = null;
try {
Enumeration<NetworkInterface> list = NetworkInterface.getNetworkInterfaces();
while (list.hasMoreElements()) {
NetworkInterface iface = list.nextElement();
if (iface == null)
continue;
Log.d(LOG_TAG, "interface=" + iface.getName());
Iterator<InterfaceAddress> it = iface.getInterfaceAddresses().iterator();
while (it.hasNext()) {
InterfaceAddress interfaceAddress = it.next();
if (interfaceAddress == null)
continue;
InetAddress address = interfaceAddress.getAddress();
Log.d(LOG_TAG, "address=" + address);
if (address instanceof Inet4Address) {
// Only pick an interface that is likely to be on the
// same subnet as the selected ChromeCast device
if (address.getHostAddress().toString().startsWith(prefix)) {