【问题标题】:How to implement idle timeout in Nativescript android application如何在 Nativescript android 应用程序中实现空闲超时
【发布时间】:2020-07-22 22:35:35
【问题描述】:

我正在用 Nativescript angular 构建一个金融应用程序。我需要一些参考资料,比如如果应用程序在设置了一些空闲超时后在后台打开并运行,它应该重定向到我们指定的页面。我无法在 Nativescript 中获得正确的参考,任何人都可以为空闲超时添加解决方案。我检查了 Nativescript 扩展活动,但无法正确获取

【问题讨论】:

    标签: nativescript-angular


    【解决方案1】:

    您应该从阅读文档开始。你需要的是生命周期钩子。

    阅读:https://docs.nativescript.org/angular/core-concepts/application-lifecycle#use-application-events

    applicationOn(suspendEvent, (args: ApplicationEventData) => {
        setTimeout(() => {
            // do what you want after a certain amouont of time
            // don't
        }, 5000); 
    });
    

    applicationOn(resumeEvent, (args: ApplicationEventData) => {
        // compare current datetime with the last datetime saved in suspendEvent event
    });
    

    不要忘记您的应用可能会被强制关闭,因此您必须根据自己的需要处理此问题

    【讨论】:

      猜你喜欢
      • 1970-01-01
      • 2012-10-28
      • 2010-12-08
      • 2016-04-10
      • 1970-01-01
      • 2011-08-19
      • 1970-01-01
      • 2021-03-07
      • 1970-01-01
      相关资源
      最近更新 更多