[英]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? (在茅草应用中使用Tizen网络JavaScript)如何启动带有百分比的Samsung Battery arc? 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. 您可以为此使用Tizen Web应用程序API 。
<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. 获取这些数据后,您可以设计一个UI来显示电池,就像系统App Green Arc一样。
Besides, You also launch the green arc application by using Application Framework API . 此外,您还可以使用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. 您可以使用ApplicationControl(在移动和可穿戴应用程序中)和RequestedApplicationControl(在移动和可穿戴应用程序中)接口来请求其他应用程序执行特定操作。 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. 通过应用程序控件,您可以使用ApplicationManager界面的launchAppControl()方法基于其功能发送启动其他应用程序的请求。 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. 您可以使用Application接口的getRequestedAppControl()方法处理传入的应用程序控制请求,并使用RequestedApplicationControl接口对传入的请求进行响应。
You can get idea about how to launch other application from you application 您可以从应用程序中了解如何启动其他应用程序
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.