Mobile Web Wearable Web

System Information: Providing Information about the Device Display, Network, Storage, and Other Capabilities

This tutorial demonstrates how you can obtain information about the device properties.

The System Information API is mandatory for both Tizen mobile and wearable profiles, which means that it is supported in all mobile and wearable devices. All mandatory APIs are supported on the Tizen Emulators.

Warm-up

Become familiar with the System Information API basics by learning about:

Task

In the System Information task, we will walk through how to access and use system information in your application.

Retrieving a Device Capability

Learning how to get a capability of the device is a basic application development skill:

  1. To get a specific capability of the device, use the getCapability() method:

    var barometer = tizen.systeminfo.getCapability("http://tizen.org/feature/sensor.barometer");
    console.log(" Barometer = " + barometer);
Note
The getCapabilities() method has been deprecated since Tizen 2.3. Use the getCapability() method instead.

For a list of available keys and their meaning, see the device capability keys (in mobile and wearable applications).

Retrieving the Current State of a Property

Learning how to retrieve information about the property states is a basic application development skill:

  1. To check the current state of the property, use the getPropertyValue() method.

    The first method parameter must be of the SystemInfoPropertyId type (in mobile and wearable applications). For the available values, see the Available properties table.

    /* Retrieve the battery property */
    tizen.systeminfo.getPropertyValue("BATTERY", onPowerSuccessCallback);
    
    /* Retrieve the cellular network property */
    tizen.systeminfo.getPropertyValue("CELLULAR_NETWORK", onCellularSuccessCallback);
    

    After retrieving a property, you can use all the details of the property in your code. The property values are returned in the success event handlers defined below.

  2. Use the power property values.

    In the following example, the battery level and charging status of the power property are printed to a console log.

    function onPowerSuccessCallback(battery)
    {
       /* Log the device battery level to the console */
       console.log("The battery level is " + battery.level);
    
       /* Check whether the device is charging */
       var charging = battery.isCharging;
    }
    
  3. Retrieve the current states of a specific device property using the getPropertyValueArray() method. For example, you can check the state of SIM cards, which are mounted in the Tizen device.

    function successCallback(properties)
    {
       console.log("The number of the returned system properties is " + properties.length);
       for (var i = 0; i properties.length; i++)
       {
          console.log("[" + (i+1) + "] SIM's state is " + properties[i].state);
       }
    }
    
    tizen.systeminfo.getPropertyValueArray("SIM", successCallback);
    
  4. Retrieve the number of system property information using the getCount() method. For example, you can check the number of SIM cards, which are installed in the Tizen device.

    console.log("The number of SIM cards in the device is " + tizen.systeminfo.getCount("SIM"));

Retrieving the Memory State

Learning how to get the memory status of the device is a basic application development skill:

  • To get the total amount of system memory, use the getTotalMemory() method:

    console.log("The total memory size is " + tizen.systeminfo.getTotalMemory() + " bytes.");
  • To get the available amount of system memory, use the getAvailableMemory() method:

    console.log("The available memory size is " + tizen.systeminfo.getAvailableMemory() + " bytes.");

Retrieving and Monitoring the Device Orientation

Learning how to retrieve information about the device orientation is a basic mobile application development skill:

  1. To retrieve the current orientation of the device, use the getPropertyValue() method of the SystemInfo interface (in mobile and wearable applications) and query the DEVICE_ORIENTATION property:

    function onDeviceOrientation(deviceOrientation)
    {
       console.log("The device orientation is now: " + deviceOrientation.status);
    }
    tizen.systeminfo.getPropertyValue("DEVICE_ORIENTATION", onDeviceOrientation);
    
  2. The user can rotate the device and change its orientation. To receive notifications about the orientation changes, use the addPropertyValueChangeListener() method of the SystemInfo interface:
    var orientationListenerId;
    orientationListenerId = tizen.systeminfo.addPropertyValueChangeListener("DEVICE_ORIENTATION", onDeviceOrientation);
    
  3. To stop receiving change notifications, use the removePropertyValueChangeListener() method of the SystemInfo interface:

    tizen.systeminfo.removePropertyValueChangeListener(orientationListenerId);
    

Receiving Notifications on Property Value Changes

Learning how to receive notifications on property value changes is a basic application development skill:

  1. Register a SystemInfoPropertySuccessCallback event handler (in mobile and wearable applications) for the property value changes using the addPropertyValueChangeListener() method of the SystemInfo interface (in mobile and wearable applications).

    The first parameter defines the property whose value changes you want to track, and the optional last parameter defines any thresholds when you want the notifications to be triggered. In the following example, an event handler is registered for the memory property value changes.

    function successCallback(memory)
    {
       console.log("The memory state is " + memory.state);
    }
    
    tizen.systeminfo.addPropertyValueChangeListener("MEMORY", successCallback);

    The method returns a watch identifier, which can be used to unregister the event handler.

  2. In the success event handler of the addPropertyValueChangeListener() method, define the notification event actions.

    In the following example, a warning about the low battery is logged to the console.

    /* Trigger a notification */
    function onSuccessCallback(battery)
    {
       console.log("Low battery: " + battery.level);
    }
    
    tizen.systeminfo.addPropertyValueChangeListener("BATTERY", onSuccessCallback);
    
  3. To unregister the event handler, use removePropertyValueChangeListener() method with the watch identifier returned from the addPropertyValueChangeListener() method.

    In the following example, the event handler is unregistered when the first change of the SIM card state is detected.

    function successCallback(properties)
    {
       for (var i = 0; i properties.length; i++)
       {
          console.log("[" + (i+1) + "] SIM's state is " + properties[i].state);
       }
       removePropertyValueChangeListener(id);
    }
    
    var id = tizen.systeminfo.addPropertyValueArrayChangeListener("SIM", successCallback);
    
Go to top