【问题标题】:onStart android titanium module not calledonStart android钛模块未调用
【发布时间】:2016-10-20 12:18:51
【问题描述】:

我想为 rootactivity onStart 事件添加一个连接,因为我正在使用打开我的应用程序的意图过滤器。我将此块添加到我的模块中,但它从未被调用。

@Override
	public void onStart(Activity activity)
	{
		// This method is called when the module is loaded and the root context is started
 
		Log.d(TAG, "[MODULE LIFECYCLE EVENT] start");
		super.onStart(activity);
	}

我也尝试在我的 index.js 上添加它,但它间歇性地工作。 大多数时候它不会被调用。

Ti.Android.currentActivity.onStart = function(e){ 
             Ti.API.info('onStart' + JSON.stringify(e));
        //     //when activity is created
     };

【问题讨论】:

    标签: appcelerator appcelerator-titanium appcelerator-mobile


    【解决方案1】:

    对于 Titanium 部分,您必须在窗口完全打开后添加 onStart 方法:

    为此,假设您的窗口 id 在 Alloy 中是 Win_1,那么这样做:

    $.Win_1.addEventListener('open', function () {
        $.Win_1.activity.onStart = function(e){ 
                 Ti.API.info('onStart' + JSON.stringify(e));
            //     //when activity is created
         };
    });
    

    您可以在经典钛金属中进行类似操作。关键是在 Titanium 中,只有在打开窗口后才能使用活动,因此您必须监听窗口的 onOpen 事件

    【讨论】:

      猜你喜欢
      • 1970-01-01
      • 1970-01-01
      • 2013-09-09
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 2014-01-19
      • 1970-01-01
      相关资源
      最近更新 更多