Yes, I listen for these events in several commercial mobile apps and they are 
reliable. I set up the listeners in the Main class initialize:
private function onInitialize(event:FlexEvent):void {
    NativeApplication.nativeApplication.addEventListener(Event.DEACTIVATE, 
onDeactivateApp);
    NativeApplication.nativeApplication.addEventListener(Event.ACTIVATE, 
onActivateApp);
}
Note that by default, iOS suspends mobile apps when they are no longer in the 
foreground so your app won't consume battery power, but Android does not. The 
reason for using these listeners in my case is to turn off a Timer that causes 
a REST API call every 20 seconds to our web service to query for any changes to 
the data in the app in which case the app will make additional calls to update 
the changed data in the app which can be expensive from time to time. 

On Android this timer would continue making these calls from the background if 
I didn't stop the Timer in the onDeactivateApp handler and restart it in the 
onActivateApp handler.

You should have no trouble calling loadURL() on your StageWebView, or native 
WebView. Incidentally, I use both Distriqt native WebView ANE and the Adobe 
StageWebView and they are both native and act exactly the same way. In fact, I 
choose to use StageWebView in some cases because I have no need of any 
additional features found in the ANE version, and it just increases the size of 
the app for no good reason.

Cheers, 

Erik

On Jan 2, 2018, at 7:00 PM, bilbosax <waspenc...@comcast.net> wrote:

Thanks Kyle.  I just googled a bunch of information on saving state for a
better user experience that listened to some NativeApplication events on
mobile, specifically Event.EXITING.  The author claims that this method is
not 100% reliable because the events don't get thrown all the time, but this
was written back in 2011.

http://www.adobe.com/devnet/flash/articles/saving_state_air_apps.html

Does anyone know if Event.ACTIVATE and Event.DEACTIVATE has become more
reliable in NativeApplication on mobile in 2018??  Anyone ever used it??



--
Sent from: http://apache-flex-users.2333346.n4.nabble.com/


Reply via email to