title: Discovery of Chromecast devices using Android MediaRouter APIs
body: <p>Discovery of Chromecast devices using Android MediaRouter APIs is not working as expected with latest mediarouter support library (version 19) and google play services version 4.2.43.</p>
  
  <p>I'm using Cast Hello Text sample app for this issue. It can be found here: <a href="https://github.com/googlecast/CastHelloText-android" rel="nofollow">https://github.com/googlecast/CastHelloText-android</a>.</p>
  
  <p>I have my chromecast device plugged into the TV and in the same network as the Android device (Sender).</p>
  
  <ol>
  <li>The app comes up and finds the Chromecast device. I override some of the relevant MediaRouter.Callback methods, so I see the onRouteAdded() being called.</li>
  <li>Later, I unplug the device from my TV. I expect to get a onRouteRemoved() event. But this never happens.</li>
  <li>The app still displays the cast icon. On selecting the device from the cast icon, the app attempts to connect to the device and fails. Now I get onRouteUnSelected() and onRouteRemoved() events and the cast icon disappears.</li>
  <li>On plugging back the device to my TV and once the device is displaying the home screen, I expect to get a onRouteAdded() event. I do not get this event even after waiting for a few minutes.</li>
  </ol>
  
  <p>This was working as expected in mediarouter library version 17 and with the preview google cast SDK. </p>
  
  <p>So has something changed in terms of when these events are fired? 
  what is the right way to find out when a chromecast device is added and when it is removed? I plan on using a custom UI with MediaRouter APIs to display the cast icon and the device list. </p>