Appcelerator Hyperloop use TiApplication Class



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

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);

附言。我已经多次在松弛频道中询问,但没有帮助

我认为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/

到目前为止,内部SDK类无法通过Hyperloop访问。但我喜欢这个主意!你能创建一个票证的应用者JIRA以便可以安排吗?

最新更新