This is a Titanium module for detecting some app events:
The user has left the app. I.e. by calling launch screen or starting a new activity from app.
The user comes back
"The screen is black" (Button Power off)
Screen reopened
You can specify the test interval (in ms) in tiapp.xml:
xml
<property name="LIFECYCLE_TESTINTERVAL" type="int">200</property>
This test interval is only for paused
and resumed
. Screen events are event triggered.
You have only to include in tiapp.xml:
xml
<module platform="android">de.appwerft.applifecycle</module>
No require
!
Just call in your app.js:
javascript
["screenon screenoff paused resumed"].split(' ').forEach(function(event){
Ti.App.addEventListener(event, function(e) {
console.log(event);
});