Q:

Can i programatically detect if there are any Chromecast devices on the current WiFi network? 

Is it possible to detect if there are any Chromecast devices on the current WiFi network.  I've seen that there's a Cast SDK but I couldn't find anything about searching for devices.  Having never worked with this SDK before, it is possible that I may have overlooked it. 

A:

Chromecast devices are discoverable using avahi with the type _googlecast._tcp
$ avahi-browse -r _googlecast._tcp
+   eth0 IPv4 Living Room                                   _googlecast._tcp     local
=   eth0 IPv4 Living Room                                   _googlecast._tcp     local
   hostname = [Living\032Room.local]
   address = [192.168.1.100]
   port = [8009]
   txt = ["st=0" "fn=Living Room" "ca=5" "ic=/setup/icon.png" "md=Chromecast" "ve=02" "id=c832a30b81ab84a706c82745438fcd64"]

A:

You can perform discovery without using the cast button; you need to use media router from v7 support library (which needs the v7 appcompat support as well) and then get an instance of the media router from your code, define a selector (which is basically a filter to possibly narrow down the devices that you are interested in) and then add a callback to start discovery.  As devices are discovered (asynchronously), your callbacks will be called.  Take a look at this sample project, specially this class which does exactly what you want.