java - Determine if an instance of a service is running and kill it -
i have android service, let's "service.java" i start instance , pass unique id each instance of service start (so don't have 2 service same uid running @ same time): intent intent = new intent(this, service.class); intent.putextra("key", uid); startservice(intent); say set variable in "service.java" uid: private string uid; @override public int onstartcommand(intent intent, int flags, final int startid) { super.onstartcommand(intent, flags, startid); if(intent != null) { bundle infobundle = intent.getextras(); this.uid = infobundle.getstring("key"); } ... } public string getuid() { return this.uid; } is there way somehow check if instance of "service.java" running given uid , kill it? i have list of key/value pairs want start instances of service @ specific times of day, if user "disables" time slot (key/value pair), want service stop. backstory: i have application