Discovery of Chromecast devices using Android MediaRouter APIs

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.

I'm using Cast Hello Text sample app for this issue. It can be found here:

I have my chromecast device plugged into the TV and in the same network as the Android device (Sender).

  1. 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.
  2. Later, I unplug the device from my TV. I expect to get a onRouteRemoved() event. But this never happens.
  3. 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.
  4. 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.

This was working as expected in mediarouter library version 17 and with the preview google cast SDK.

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.


There is a bug in the latest version of Android SDK/Play services that causes the behavior you are seeing. This will be fixed in the next release of SDK and Google Play services.

Need Your Help

How to move(animate) a button to a certain position on click and return to original position if click elsewhere?

javascript jquery html css

Suppose we have a button <button id="btn">I'm a button</button>.It's position is right in the center.Now when i click this button it should move to let's say top left corner.When click

How to collapse Android notifications?

android push-notification android-c2dm

I'm sending a C2DM update to my Android app every 1/2 hour, which creates a Notification. Problem is, when I wake up in the morning I get 15 Notifications queued up in the status bar.