[AC-3549] OnLifecycleEvent doesn't work on viewproxy
GitHub Issue | n/a |
---|---|
Type | Bug |
Priority | n/a |
Status | Closed |
Resolution | Not Our Bug |
Resolution Date | 2016-04-28T04:24:22.000+0000 |
Affected Version/s | n/a |
Fix Version/s | n/a |
Components | n/a |
Labels | Android, Module |
Reporter | Rainer Schleevoigt |
Assignee | Shak Hossain |
Created | 2016-04-26T08:06:50.000+0000 |
Updated | 2016-04-28T04:24:22.000+0000 |
Description
Hi,
in my special view I need access to lifecycle events for rerendering etc.
The only example I found in net is https://github.com/appcelerator-modules/ti.admob/blob/master/android/src/ti/admob/ViewProxy.java
My viewproxy is a simple clone of it: https://github.com/AppWerft/Ti.AudioVisualizerView/blob/master/android/src/ti/audiovisualizerview/ViewProxy.java
The event never appears. If I add the init routine in view constructor, then I see the visualizer, but not after resuming.
Does the event listener depends of a condition? The module will called after open event of window
The same issue, if I add the code to native View: https://github.com/AppWerft/Ti.AudioVisualizerView/blob/master/android/src/ti/audiovisualizerview/VisualizerImageView.java
Here the code example:
Hello, Thanks for your query. Here is some information which may help you. On android lifecycle events are attached to activities. For example onPause event of an activity is fired when the activity is paused. To make a proxy to respond to these events first, in the module proxy, override the activity lifecycle callbacks you want to respond to. Then, in the JavaScript application, when you create the module proxy, assign its lifecycleContainer property to either a Window or TabGroup object to listen for that object's lifecycle events to trigger the module proxy's activity lifecycle callbacks. Like this :
[Documentation Link](http://docs.appcelerator.com/platform/latest/#!/guide/Android_Module_Architecture-section-43289000_AndroidModuleArchitecture-ActivityLifecycleEvents) Thanks
Thanks for quick answer. In my case the calling of module is after opening of window. Is it a problem? Second: I found in TiUIImageView.java the same pattern. The listener is binded an View, not on Viewproxy and in JS-code I dont see the lifecycle binding. Or is it only needed for special applications? Is there a difference TiContext.OnLifecycleEvent;and and TiLifecycle.OnLifecycleEvent? Cheers!
Hello, First: When the window is opened the activity has already gone pass onResume and onStart event. You can not catch these events now. But the the activity can go through these events again depending on the app structure. Second: While developing module you have to make use of module development API. [LINK](http://docs.appcelerator.com/module-apidoc/latest/android/index.html) Thanks