java - How to start a Service in Android? -


i have 3 classes in separate java files: try.java, hu.java, , first.java.

the hu class not activity, it's service, , when first.java runs have code calls hu class:

public class first extends activity  {     @override     public void oncreate(bundle savedinstancestate)      {         super.oncreate(savedinstancestate);         intent svc = new intent(this, hu.class);         startservice(svc);         finish();     } } 

i know code works, because hu class called.

since hu class service, "always on top button", , use ontouchlistener register click event, , part works. not work part call try class when button clicked.

that in separate java file; here code:

@override public boolean ontouch(view v, motionevent event)  {     toast.maketext(this,"overlay button event", toast.length_short).show();     intent svc1 = new intent(this, try.class);     startservice(svc1);      return false; } 

i use same logic here, not working.


Comments