I have setup a custom Cast Dialog and added it using:
castButton.setDialogFactory(new DialogFactory());
My custom dialog retrieves available cast devices using the below code and display them as a list
MediaRouter.getInstance(getContext()).getRoutes();
How can I start casting to a CastDevice
chosen from the above list?
Solved using:
MediaRouter.getInstance(context).selectRoute(route)
To disconnect I did:
MediaRouter.getInstance(context).unselect(MediaRouter.UNSELECT_REASON_DISCONNECTED)