Starting Android services by intent vs. by instance creation -
Starting Android services by intent vs. by instance creation -
it's understanding android services supposed singletons - no more 1 class instance running @ time. you're supposed start them via intents, opposed to
myservice mse = new myservice();
however, in google's in-app billing sample, that's in dungeons.java, line 235. it's legal.
i'm wondering, if start service this, framework later recognize it's running? in other words, if seek phone call startservice() on same service later on, framework recognize instance of service exists , dispatch startservice() calls it?
if instantiate service straight instead of using intents guarantees service run within activities process. if activity should killed downwards goes service too. bad practice? depends on wanted. if need service live through potential shutdowns of activities yes that's bad thing do. if don't care or app can tolerate shutdowns it's ok. however, i'd argue if need background job running can stopped when activity stops need utilize asynctask , not service.
android android-service
Comments
Post a Comment