I have a requirement of a project in which My Application needs to know that which Cast device is my device is currently connected to. For e.g. if i cast a video using YouTube then my application should know that Now i am connected to Cast Device . As seen in the Google Cast API, the MediaRouter API callbacks will only give callbacks to the application in which it is implemented not to any other applicaton. Also I did not find any System Broadcast when some Cast Device is connected.
The experimentation that I did was to Introduce some Logs in Android AOSP Code. According to me Whenever any application invokes a listener for Cast Device it internally call onRouteAdded() API of MediRouter.Callback which is invoked by dispatchRouteAdded() API in Media Router Class. But the logs that I have introduced in these API's are never called.
Also I introduced Logs in resolveStatusCode() in RouterInfo Class to know about the Status whether the device is STATUS_CONNECTED STATE, but it always return STATUS_NONE
Can some one also give me some pointers how can i implement a Broadcast for Cast Device Connection in the AOSP framework , so that i can test it in Nexus 5 with my Custom ROM.