Detecting Network Disconnection in Samsung Smart TV

Samsung Smart TV

Smart TV applications make regular use of the Internet to update their contents. The Internet usage varies ranging from collecting user details, user view stats, payment processing etc. The ability of the Smart TV applications to make use of the internet has enabled a plethora of services for the Smart TV user right from the TV. So if the Internet services are disabled, a lot of the Smart TV applications will get affected, because most of the applications in Smart TV depend on the Internet for their data. While developing applications for the Samsung Smart TV platform, the developer should keep the internet connectivity in his mind. Any application developed for Samsung Smart TV should be able to detect the availability of Internet and will then have to take corresponding action, based on the internet availability. Samsung Smart TV application policy states that the developed application should handle all the errors related to the network connectivity by itself. This article aims at detecting the network connectivity in a Samsung Smart TV application code using the APIs provided by Samsung Smart TV.

Basic working principle

The basic working principle of Samsung Smart TV network connectivity checkup is as follows. The application makes use of a plugin to check for internet connectivity continuously in user defined intervals. Once the internet connectivity or disconnection is detected, the plugin will call the corresponding callback, which the user can use to identify the action and in turn, can take necessary changes with the application like showing an alert information to the user, and many other tasks.


By detecting the network connectivity through application and showing a corresponding alert to the user or take defensive action has its own set of advantages. The following are some of the advantages.

  • The user gets to know the disconnection and can prevent actions like making a payment or entering other input information
  • Prevent a transaction from causing
  • Prevent a database operation and hence avoiding data loss
  • Taking necessary actions so that the application runs without any interruption and hence avoiding that strange behaviour.

Including the library

The functions for checking network connectivity can be called by including the following library to the application code.

<object id="pluginObjectNetwork" border="0" classid="clsid:SAMSUNG-INFOLINK-NETWORK"></object>

Once the plugin is included, then the functions for checking network connectivity is already available for the developer to use in his/her application. Here we are going to use the CheckGateway function to check for network connectivity. The CheckGateway function is passed with the current active network interface. The passed network interface is queried continuously for network connection in the user specified interval. It returns a true or a false based on the network connectivity. Based on the return value, the corresponding action is taken. The below code sample just prints the disconnection of network in the console. In a real world, this scenario can be used for taking further necessary actions.

var networkPlugin = document.getElementById('pluginObjectNetwork');

var internetConnectionCheckInterval = 500;

function cyclicInternetConnectionCheck() {

   if (!checkConnection()) { //called when a network disconnection takes place
       //alert the user
   setInterval('cyclicInternetConnectionCheck', internetConnectionCheckInterval);

function checkConnection() {
   var gatewayStatus = 0;
   currentInterface = networkPlugin.getActivityType();
   if (currentInterface === -1) {
       return false;
   gatewayStatus = networkPlugin.CheckGateway(currentInterface);
   if (gatewayStatus !== -1) {
       return false;
   return true;

The GetActiveType function will retrieve the current active connection interface for the TV. This may be a wifi connection, a LAN or a bluetooth. This function returns a -1 when there are no active network connections in the TV.  Further functionalities in the logic are explained in the code by means of comments.


This article explained the method to detect any disconnection in network connectivity in a Samsung Smart TV. This action will help the developer take necessary action like indicating the user, stopping further data transfer, stopping money transactions etc. which could save the data from getting corrupted and thereby avoiding user distress. The network disconnection event can be used to take further constructive action, that will help the application in the long run.

No Comments

You can leave the first : )

Leave a Reply

Your email address will not be published. Required fields are marked *