Johann
Johann

Reputation: 29875

Communicating between Android phone and Android TV

Does Android have any built-in communication APIs that lets a native Android app running on a phone communicate with a native Android app running on Android TV? The only solution I can think of is where the Android TV app creates a socket and the client app on the phone would connect to this socket.

EDIT: I'm looking for a solution where no user interaction is required to setup the communication. Bluetooth requires the user to pair devices. NFC requires being very close to the device.

Upvotes: 1

Views: 2724

Answers (3)

thanhbinh84
thanhbinh84

Reputation: 18464

There is a guide from the android developer website

https://developer.android.com/training/connect-devices-wirelessly

  1. Network service discovery (NSD)
  2. P2P connections with Wi-Fi Direct

Upvotes: 0

Jszn
Jszn

Reputation: 133

Yep, I implemented this by two ways, since P2P is disable on a lot of Android TVs, I kept socket and firebase solution, both works: for socket purpose: https://jayrambhia.com/blog/android-wireless-connection-1

For firebase, I did a page where the firebasetoken is display in a QRCode, the mobile app scan it, and we send a notification with the auth params to the Android TV App wich can connect to our back end.

Upvotes: 2

CommonsWare
CommonsWare

Reputation: 1007554

Does Android have any built-in communication APIs that lets a native Android app running on a phone communicate with a native Android app running on Android TV?

You have the same options that you with any pair of Android devices:

  • Direct ordinary sockets, if the two devices happen to be on the same WiFi LAN segment or are otherwise directly reachable, and you are comfortable with the security ramifications of having an open socket connection

  • WiFi Direct (where available)

  • Bluetooth

  • Indirect communication through Internet-hosted facilities (e.g., FCM) or possibly some locally-reachable server that is not on the Internet (e.g., WebRTC)

  • NFC, though probably few Android TV devices have NFC support

About the only thing that I can think of that might be more unique for Android TV would be those that offer an infrared (IR) receiver, but I have no idea how much apps can tap into that, and few Android devices have an IR transmitter.

Upvotes: 1

Related Questions