Romulus Urakagi Ts'ai Romulus Urakagi Ts'ai - 2 months ago 5x
Android Question

How to detect if Chromecast is already connected on Android Sender?

I have an Android sender for Google Cast, and a Chromecast. I can cast video to a TV, and the cast button on actionbar becomes white.

Now comes the question. When I leave the sender app, Chromecast continues to play video. This is what I want. But when I re-open the sender app, I don't know how to detect if the devices is already running my receiver, so I need to automatically join current session.

Can anyone help? Thank you!


joinApplication() has three different variations; in one of them, you can specify an applicationId and join happens successfully only if the cast device is running that application.

If you want to join when not only the same app is running, but also still in the same session that you had started before, you need to persist the sessionId each time you launch an app and then use another variation of the joinApplication() that takes an applicationId and a sessionId.