简体   繁体   中英

Samsung gear2 Tizen. How to launch Battery meter

(Using Tizen web javascript in a wantch app) How do I launch the Samsung Battery arc with percentage? I mean that green arc showing the percentage left of the batterym that seems to be part of the samsung pre.installed apps... I already know how to get the battery info, but not how to launch tha battery info app... ?

You can use Tizen Web Application API for that.

<script>
       function getBatteryState() 
       {
          var message = "";

          var charging = battery.charging;
          var chargingTime = getTimeFormat(battery.chargingTime);
          var dischargingTime = getTimeFormat(battery.dischargingTime);
          var level = Math.floor(battery.level * 100);

          if (charging == false && level < 100) 
          { 
             /* Not charging */
             message = dischargingTime.hour + ":" + dischargingTime.minute + " remained.";
             if (battery.dischargingTime == "Infinity") 
             {
                message = "";
             }
          }
          else if (charging && level < 100) 
          {  
             /* Charging */
             message = "Charging is complete after " 
                       + chargingTime.hour + ":" + chargingTime.minute;
             if (battery.chargingTime == "Infinity") 
             {
                message = "";
             }
          }
          else if (level == 100) 
          {
             message = "Charging is completed";
          }

          document.querySelector('#charging').textContent = charging ? 'charging..' : 'Please connect the charger.';
          document.querySelector('#level').textContent = level + "%";
          document.querySelector('#progress').value = level;
          document.querySelector('#message').textContent = message;
       }

       /* Time is received in seconds, converted to hours and minutes, and returned */
       function getTimeFormat(time) 
       {
          /* Time parameter is second */
          var tempMinute = time / 60;

          var hour = parseInt(tempMinute / 60, 10);
          var minute = parseInt(tempMinute % 60, 10);
          minute = minute < 10 ? "0" + minute : minute;

          return {"hour": hour, "minute": minute};
       }
    </script>

Here is output

在此处输入图片说明

For more goto this link

After getting these data you can design a UI to show battery in just like system App Green Arc.

Besides, You also launch the green arc application by using Application Framework API .

You can request other applications to perform specific operations using the ApplicationControl (in mobile and wearable applications) and RequestedApplicationControl (in mobile and wearable applications) interfaces. The operations can be, for example, making a phone call, browsing local files so the user can pick an image of their choosing, or playing a video in a video player.

With the application control, you can send a request to launch other applications based on their functionality using the launchAppControl() method of the ApplicationManager interface. The launched provider application performs a specific operation and sends back a response.

Your application can export application control functionality. This means that the application can register itself as a provider application, allowing it to receive application control requests from other applications. You can handle an incoming application control request using the getRequestedAppControl() method of the Application interface, and respond to the incoming request using the RequestedApplicationControl interface.

You can get idea about how to launch other application from you application

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM