I want to use background Service in my Titanium Application.
I used every code which need to insert in Titanium Android application.
In TiApp.xml file : Register Service here
<services>
<service url='BGServ.js' type="interval"/>
</services>
Here "BGServ.js" file is placed in my app/lib folder.
In BGServ.js file : Our Service file code
var service = Titanium.Android.currentService;
var intent = service.intent;
Ti.API.info('Background Service Started');
Ti.API.info('Background Service of Platform : ' + Titanium.Platform.osname + ' Started');
service.addEventListener('resume', function(e) {
Titanium.API.info('Service code resumes, iteration ' + e.iteration);
});
service.addEventListener('pause', function(e) {
Titanium.API.info('Service code pauses, iteration ' + e.iteration);
});
In index.js file : Here we creating Service Intent
var intent = Titanium.Android.createServiceIntent({
url : '/BGServ.js'
});
intent.putExtra('interval', 1000);
intent.putExtra('message_to_echo', 'Test Service');
Titanium.Android.startService(intent);
Issue : Android Service is not working in my project. In BGServ.js having a Ti.API.info() which also not printed in console. I am struct here help me.
TiSDK Version : 3.5.0 GA
Thanks,
Abidhusain
Found the Solution of Background Service for Android in Titanium Appcelerator
Note that here in url attribute no need to add "\" ahead of file name.
And also put Background Service file in only "assets" folder on your application.
Note that here in url attribute no need to add "\" ahead of file name.
If anyone found any other solution then replay here.
Thanks,
Abidhusain