android - Keep service running in background even user clear memory -
i have service follows: public class service extends service { private static final string tag = "myservice"; @override public void oncreate() { super.oncreate(); log.d(tag, "oncreate"); } @override public ibinder onbind(intent intent) { return null; } public void ondestroy() { toast.maketext(this, "my service stopped", toast.length_long).show(); log.d(tag, "ondestroy"); } @override public int onstartcommand(intent intent, int flags, int startid) { intent intents = new intent(getbasecontext(),mainactivity.class); intents.setflags(intent.flag_activity_new_task); startactivity(intents); toast.maketext(this, "my service started", toast.length_long).show(); log.d(tag, "onstart"); return start_not_sticky; } } it worked well, , can check service running when go application setting. howe