0
votes

I want to add a hookup to the rootactivity onStart event because I am using an intent filter that opens my app. I added this block to my module but it never gets called.

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

I Also tried to add this on my index.js but it is intermittently working . most of the time it is not called.

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

1 Answers

0
votes

For Titanium part, you will have to add onStart method after the window is completely opened:

To do so, let's say if your window's id is Win_1 in Alloy, the do it this way:

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

You can do it similarly in classic titanium. The point is that in Titanium an activity is only available after a window is opened and so you must listen to window's onOpen event