I\'m writing a chromecast receiver application that will (hopefully) allow me to remotely put alert messages up on my TV to serve as reminders.
My plan was to have a
You can programmatically scan for cast devices and connect to them if needed. Steps are:
mMediaRouter
mMediaRouteSelector = new MediaRouteSelector.Builder()
.addControlCategory(
CastMediaControlIntent
.categoryForCast(YOUR_APP_ID)).build();
mMediaRouter.addCallback(mMediaRouteSelector, mMediaRouterCallback,
MediaRouter.CALLBACK_FLAG_PERFORM_ACTIVE_SCAN);
onRouteAdded()
and onRouteRemoved()
of your callback (i.e. mMediaRouterCallback
) will be called as routes are discovered or removed. You can maintain a list of routes in your app and keep them up to date by using these two callbacks.mMediaRouter.selectRoute(aRouteInfo)
. Then the onRouteSelected()
of your callback will be called and you can extract the cast device as usual and do as you please. These said, remember that if you want to show a notification to users on TV your app should be running on the chromecast at the time you want to send the notification.