Communicate
-- Connect and communicate with a TV application from your mobile app.

Discover TVs from a Mobile Application

From you mobile app, the first thing you'll want to do is find compatible TVs to interact with. Your mobile device and TV device need to be on the same WIFI network to work together. The mobile APIs provide a simple way to find TVs on your network. Typcially, you will use the APIs to start "scanning" the network for TVs and display a list to the user as they are found. Then allow the user to select a device to connect to.

The general mobile workflow is:

Start the Discovery Process

Listen for Events indicating services Added/Removed.Present the list of discovered TVs to the user

Stop the Discovery Process
Once the user has selected a TV from the list

Example Android API Usage

// Get an instance of Search
final Search search = Service.search(getContext());
// Add a listener for the onServiceFound event
search.setOnServiceFoundListener(
new OnServiceFoundListener() {
@Override
public void onFound(Service service) {
Log.d(LOGTAG, "Search onFound() " + service.toString());
// Add service to a visual list where your user can select.
// For display, we recommend that you show: service.getName()
}
}
);
// Add a listener for the onServiceLost event
search.setOnServiceLostListener(
new OnServiceLostListener() {
@Override
public void onLost(Service service) {
Log.d(LOGTAG, "Search onLost() " + service.toString());
// Remove this service from the display list
}
}
);
// Add a listener for the onStop event
search.setOnStopListener(
new OnStopListener() {
@Override
public void onStop() {
Log.d(LOGTAG, "Search onStop() services found: " + search.getServices().size());
}
}
);
// Start the discovery process with a timeout of 15 seconds.
search.start(1500);
// You can also stop the discovery process after some amount of time. Preferably once the user has selected a service to work with
search.stop();

Launching Installed TV App from a Mobile Application

Before you can work with an installed TV app, you must first know the "id" of the TV application you want to work with. You can get your tv app id when you register your app in Samsung Apps.

Once the TV app has been released into Samsung Apps, you must use the supplied app id.