java - How can I create an android service that dalvik will not kill? -
before begin question, want preface with: know it's bad idea force service run forever... not care.
this application not consumer use. not going on app store. use only.
alright, have unused htc sensation running 4.0.3 (ics) sitting around, , have volunteered local theatre task. task ring on cue whenever needed in show. don't want sim card in because might accidentally call phone during show when not supposed ring.
so created fake phone application receives signal via tcp server have set send signals devices on lan. right have listener running in infinite loop in service. am, however, still experiencing service not responding tcp signals.
i appreciated if android guru's give me hints/tips making service reliable possible, good/bad coding techniques aside want possible make service unkillable. phone has 1 job now, , listening incoming messages, no matter what.
things have done far:
created service (and launched separate thread service) used startforeground(id, notification); activated deviceadmin , created wakelock
anything else guys can think of?
first idea pops mind setting alarmmanager checks every 5 seconds whether or not service running. this describes method see whether service running. , if service not running can restart it.
using , startforeground()-method may work.
kind regards
Comments
Post a Comment