Last active
September 3, 2021 14:43
-
-
Save ricardoalcocer/5200359 to your computer and use it in GitHub Desktop.
Appcelerator Titanium Android Background Service
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
// start service | |
var SECONDS = 20; // every 10 seconds | |
var intent = Titanium.Android.createServiceIntent({ | |
url: 'logservice.js' | |
}); | |
intent.putExtra('interval', SECONDS * 1000); // Needs to be milliseconds | |
Titanium.Android.startService(intent); | |
// stop service | |
var intent = Titanium.Android.createServiceIntent({ | |
url: 'logservice.js' | |
}); | |
Titanium.Android.stopService(intent); |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
// for Alloy this file goes in /assets | |
Ti.API.info('write something'); |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
<android xmlns:android="http://schemas.android.com/apk/res/android"> | |
<services> | |
<service url="logservice.js" type="interval"/> | |
</services> | |
</android> | |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
So what does this do exactly ?
Can I use this to write a function inside logservice.js and have it run every X minutes ?
Will it work and the function be executed when the app is fully closed and device restarted ?
thanks in advance