简体   繁体   English

如何捕获是否已打开应用程序? (NativeScript)

[英]how to capture if an application has been opened? (NativeScript)

I would like to capture an event when an application is opened. 我想在打开应用程序时捕获一个事件。

Ex: The Waze app is open, from this moment I would like to capture an event and decide whether the application can continue its running or not . 实例:在Waze的应用程序是开放的,从这一刻开始,我想捕捉事件,并决定申请是否可以继续运行与否

Yes you can do in Ionic you can see .run function in ionic inside that you can write a function for the app what it should do when it is opened. 是的,您可以在Ionic中进行操作,可以在ionic中看到.run函数,您可以为该应用编写函数,该函数在打开时应执行的操作。

app.run(function($ionicPlatform) {
  $ionicPlatform.ready(function() {
    if(window.cordova && window.cordova.plugins.Keyboard) {
      // Hide the accessory bar by default (remove this to show the accessory bar above the keyboard
      // for form inputs)
      cordova.plugins.Keyboard.hideKeyboardAccessoryBar(true);

      // Don't remove this line unless you know what you are doing. It stops the viewport
      // from snapping when text inputs are focused. Ionic handles this internally for
      // a much nicer keyboard experience.
      cordova.plugins.Keyboard.disableScroll(true);
    }
    if(window.StatusBar) {
      StatusBar.styleDefault();
    }


       // write your function for capturing an event and make it use where ever you need.

  });
})

.run will run automatically when an app is open and set everything you need for that app so try do you your stuff inside it so that will make you easy for you task .run将在应用打开时自动运行,并设置该应用所需的所有内容,因此请尝试在其中添加内容,以便您轻松完成任务

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

相关问题 nodejs如何控制已经打开的浏览器 - How to control the browser that has been opened by nodejs 如何捕获复选框是否已被选中? - How to capture whether a checkbox has been checked or not? 如何捕获在Java Web应用程序中关闭打开的Excel文件的事件 - How to capture the event of closing an opened excel file in java web application 如果按下回车键,如何捕获? - How do I capture if the enter key has been pressed? javascript - 知道链接是否已经打开 - javascript - know if a link has already been opened 如何在Python中检测Web浏览器是否打开了本地HTML文件 - How to detect in Python if a local HTML file has been opened by a web browser JS - 单击并打开另一个手风琴项时,如何关闭手风琴项? - JS - How can I make an accordion item close when another has been clicked on and opened? 如何使用 jquery 检测对话框是否已打开? - How can I use jquery to detect whether a dialog has been opened? 打开连接后如何从javax websocket服务器获取消息 - How to get message from javax websocket server when connection has been opened 如何检测搜索结果页面中的项目已在另一个浏览器选项卡中打开 - How to detect an item in a search result page has been opened in another browser tab
 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM