简体   繁体   English

Tizen Web:如何回拨有关启动哪个应用程序的信息

[英]Tizen Web : How to get a call back regarding which application is launched

I am developing an App Lock app. 我正在开发一个App Lock应用程序。 Here whenever an application is launched by user i want a callback in my app regarding which app is launched. 在这里,每当用户启动应用程序时,我都希望在我的应用程序中回调有关启动哪个应用程序的信息。 Based on some predefined settings i want to show lock screen. 基于一些预定义的设置,我想显示锁定屏幕。

I don't know which API i should use. 我不知道我应该使用哪个API。 Whats the in "TI ZEN" using which i can monitor the app launch.Basically i need to know which application is in foreground. “ TI ZEN”中的内容可用来监视应用程序的启动。基本上,我需要知道哪个应用程序处于前台。

Using the existing API i have a list of applications installed but need to monitor them. 使用现有的API,我安装了一系列应用程序,但需要对其进行监视。

    function onError(err) {
    console.log('Error occurred : ' + err.message);
    }

function onsuccess(applications) {
    var appInfo;
    for (var i = 0; i < applications.length; i++) {
    appInfo = applications[i];
    console.log('Application ID: ' + appInfo.id);
    console.log('Icon Path: ' + appInfo.iconPath);
    console.log('Name: ' + appInfo.name);
    console.log('Version: ' + appInfo.version);
    console.log('Show: ' + appInfo.show);
    }
}

tizen.application.getAppsInfo(onsuccess, onError);

My Answer is a bit late, but in case you still need it - 我的答案有点晚了,但是如果您仍然需要它-

Native API 本机API

I cant tell what version of Tizen you are using, but for Tizen 3.0, you can get callbacks for whenever an app in launched using the Application Manager API (native API). 我无法告知您使用的是哪个Tizen版本,但是对于Tizen 3.0,只要使用Application Manager API (本机API)启动应用程序,您就可以获得回调。

Specifically, the function app_manager_set_app_context_event_cb will give you callbacks for when an app is launched or terminated. 具体来说,函数app_manager_set_app_context_event_cb将为您提供启动或终止应用程序时的回调。

Web API 网络API

Currently the Javascript API does not have the corresponding function. 当前,Javascript API没有相应的功能。

Ideally, you need to create a hybrid application and call the above mentioned native API - its not too difficult. 理想情况下,您需要创建一个混合应用程序并调用上述本地API-不太困难。

If, however, you want to stick to JavaScript, you can keep calling the function tizen.application.getAppsContext() to monitor which apps are currently running. 但是,如果您想使用JavaScript,则可以继续调用函数tizen.application.getAppsContext()来监视当前正在运行的应用程序。 You won't get a callback when an app launches, but you can poll the above method once every half second to check the currently running apps and kill the appp if you want it locked. 应用启动时不会收到回调,但是您可以每半秒轮询一次以上方法,以检查当前正在运行的应用,如果希望将其锁定则将其杀死。

Note that polling too often might affect device performance. 请注意,轮询过多可能会影响设备性能。

You have to use Tizen Background Service application as your app have to always check which app is coming to foreground. 您必须使用Tizen后台服务应用程序,因为您的应用程序必须始终检查哪个应用程序即将出现。

And for detecting app launching, you may use Tizen App Control API. 为了检测应用程序启动,您可以使用Tizen App Control API。

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

相关问题 如何在Web应用程序中处理会话竞争条件? - How to Treat Race Condition of Session in Web Application? wait()如何在Java中获取Lock - How does wait() get the Lock back in Java 如何从数据库加载和重置Web应用程序中的配置映射 - How to load from database and reset Configuration mapping in Web application 如何向 ASP.NET Web 应用程序添加全局锁? - How to add a global lock to ASP.NET web application? Spring-Hibernate ::如何确保数据从DB正确传输到Web Server /最终用户浏览器并返回 - Spring-Hibernate:: How to Ensure data is transmitted correctly from the DB to the Web Server / end user browser and back 防止Web应用程序中的同时事务 - Prevent simultaneous transactions in a web application 在Web应用程序中锁定XML文件 - Locking XML file in Web Application 如何禁止2个用户使用MySQL在Web应用程序中编辑相同数据(如果可能,请使用CodeIgniter) - How to forbid 2 users to edit the same data in a web application using MySQL (with CodeIgniter if possible) 使用文本文件作为非常简单的Web应用程序的存储,如何进行锁定? - Use a text file as storage for a very simple web application, how to do locking? 使用带锁的函数调用或虚拟调用哪个更快? - Which is faster, a function call with a lock, or a virtual call?
 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM