android service not working when app enters background in titanium -
hi try develop simple android service application using titanium following tutorial. works when application in foreground, when press button kills app , service not running.
below code used , log got when app enters background. please let me know going wrong. (i using titanium sdk 2.0.1.ga2 , android sdk 2.2 android runtime v8/rhino].
my app.js file:
var intent = titanium.android.createserviceintent( { url: 'logservice.js' } ); // service should run code every 10 seconds. intent.putextra('interval', 10000); // message service should 'echo' intent.putextra('message_to_echo', 'titanium rocks!'); var service = titanium.android.createservice(intent); 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); /* if (e.iteration === 3) { titanium.api.info('service code has run 3 times, stop it.'); service.stop(); } */ }); service.start(); and logservice.js file is:
var service = titanium.android.currentservice; var intent = service.intent; var message = intent.getstringextra("message_to_echo"); titanium.api.info("hello world! service. have say: " + message); i included service tag in tiapp.xml
and log getting when press button:
w/keycharactermap( 322): no keyboard id 0 w/keycharactermap( 322): using default keymap: /system/usr/keychars/qwerty.kcm.bin e/tibaseactivity( 322): (main) [62040,92891] layout cleanup. d/dalvikvm( 322): gc_for_malloc freed 9526 objects / 480272 bytes in 115ms d/dalvikvm( 322): gc_for_malloc freed 12770 objects / 693152 bytes in 80ms d/dalvikvm( 322): gc_for_malloc freed 8846 objects / 508872 bytes in 77ms d/dalvikvm( 322): gc_for_malloc freed 8976 objects / 512112 bytes in 78ms d/eventemitter( 322): callhandler function not available resume w/tianalyticssvc( 322): (thread-15) [29966,122857] analytics service started i/tianalyticssvc( 322): (thread-15) [69,122926] sending 1 analytics events. d/dalvikvm( 322): gc_for_malloc freed 7386 objects / 436936 bytes in 87ms d/nativecrypto( 322): freeing openssl session d/dalvikvm( 322): gc_for_malloc freed 1581 objects / 89648 bytes in 71ms i/dalvikvm-heap( 322): grow heap (frag case) 3.588mb 87396-byte allocation d/dalvikvm( 322): gc_for_malloc freed 12 objects / 712 bytes in 76ms d/dalvikvm( 322): gc_for_malloc freed 956 objects / 49400 bytes in 88ms i/dalvikvm-heap( 322): grow heap (frag case) 3.624mb 87396-byte allocation d/dalvikvm( 322): gc_for_malloc freed 0 objects / 0 bytes in 75ms w/tianalyticssvc( 322): (thread-15) [3772,126698] stopping analytics service d/sntpclient( 60): request time failed: java.net.socketexception: address family not supported protocol
Comments
Post a Comment