【问题标题】:Appcelerator Hyperloop use TiApplication ClassAppcelerator Hyperloop 使用 TiApplication 类
【发布时间】:2018-05-09 04:11:35
【问题描述】:

我正在尝试使用 Hyperloop 来使用 isCurrentActivityInForeground 内部的 org.appcelerator.titanium.TiApplication 方法

https://github.com/appcelerator/titanium_mobile/blob/master/android/titanium/src/java/org/appcelerator/titanium/TiApplication.java

我尝试了以下方法和其他一些方法,但我无法要求上课 - 有什么建议吗?

var TiApplicationClass = require('org.appcelerator.titanium.TiApplication');
var TiApplication = new TiApplicationClass;
var isInForeground = TiApplication.isCurrentActivityInForeground();

Ti.API.log("isInForeground");
Ti.API.log(isInForeground);

PS。我曾多次在松弛频道中询问过,但没有任何帮助

【问题讨论】:

    标签: titanium appcelerator appcelerator-titanium appcelerator-hyperloop


    【解决方案1】:

    我认为 benCoding.Android.Tools 模块是你需要的:https://github.com/benbahrenburg/benCoding.Android.Tools

    if (OS_ANDROID) {
        var platformTools = require('bencoding.android.tools').createPlatform(),
            wasInForeGround = true;
    
        setInterval(function() {
            var isInForeground = platformTools.isInForeground();
    
            if (wasInForeGround !== isInForeground) {
                Ti.App.fireEvent(isInForeground ? 'resumed' : 'paused');
    
                wasInForeGround = isInForeground;
            }
        }, 3000);
    }
    

    示例代码归功于 Fokke Zandbergen:http://www.tidev.io/2014/01/28/paused-resumed-events-on-android/

    【讨论】:

    【解决方案2】:

    目前无法通过 Hyperloop 访问内部 SDK 类。但我喜欢这个主意!你能创建一个Appcelerator JIRA 的工单以便安排它吗?

    【讨论】:

    • 嗨,Hans,我有一张与此相关的票有一段时间了 - jira.appcelerator.org/browse/… 如果您希望我创建一个新的超高铁相关票,请告诉我
    猜你喜欢
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 2016-12-21
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    相关资源
    最近更新 更多