首页
学习
活动
专区
圈层
工具
发布
社区首页 >问答首页 >Appcelerator Hyperloop使用TiApplication类

Appcelerator Hyperloop使用TiApplication类
EN

Stack Overflow用户
提问于 2018-05-09 12:11:36
回答 2查看 186关注 0票数 1

我正在尝试使用超循环在org.appcelerator.titanium.TiApplication中使用isCurrentActivityInForeground方法

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

我已经尝试了以下和其他一些方法,但我无法要求这个类-有什么建议吗?

代码语言:javascript
复制
var TiApplicationClass = require('org.appcelerator.titanium.TiApplication');
var TiApplication = new TiApplicationClass;
var isInForeground = TiApplication.isCurrentActivityInForeground();

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

PS。我在闲置的渠道中问了很多次,但都没有帮助。

EN

回答 2

Stack Overflow用户

发布于 2018-05-09 18:31:44

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

代码语言:javascript
复制
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/

票数 1
EN

Stack Overflow用户

发布于 2018-05-10 21:57:18

到目前为止还不能通过Hyperloop访问内部SDK类。但是我喜欢这个想法!您是否可以在Appcelerator JIRA中创建票证,以便对其进行计划?

票数 1
EN
页面原文内容由Stack Overflow提供。腾讯云小微IT领域专用引擎提供翻译支持
原文链接:

https://stackoverflow.com/questions/50245392

复制
相关文章

相似问题

领券
问题归档专栏文章快讯文章归档关键词归档开发者手册归档开发者手册 Section 归档