How Android determines whether the specified service is running "service"

Source: Internet
Author: User

Tag: Color size + + Run list ati ISS tostring running

How to tell if a service is running:

/*** How to determine if a service is running * *@paramMcontext *@paramServiceName is the class name of the package name + service *@returntrue to indicate that the service is not running, false*/     Public Static Booleanisservicework (Context mcontext, String serviceName) {BooleanIswork =false; Activitymanager Myam=(Activitymanager) mcontext. Getsystemservice (Context.activity_service); List<RunningServiceInfo> myList = myam.getrunningservices (40); if(Mylist.size () <= 0) {            return false; }         for(inti = 0; I < mylist.size (); i++) {String mname=Mylist.get (i). Service.getclassname (). toString (); if(Mname.equals (serviceName)) {iswork=true;  Break; }        }        returniswork; }

A possible usage scenario is to force a specified service to stop.

Questions:

1. In the above instruction logic, there is a suspicious parameter: 40. How does this parameter work?

2. Leave a future ...

How Android determines whether the specified service is running "service"

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.