This example will test whether a service is running in android if you know it’s package name.
Run this sample of code to check this.

private boolean checkMyServiceRunningOrNot() {
    ActivityManager manager = (ActivityManager) getSystemService(ACTIVITY_SERVICE);
    for (RunningServiceInfo service : manager.getRunningServices(Integer.MAX_VALUE)) {
        if ("com.example.your_Service".equals(service.service.getClassName())) {
            return true;
        }
    }
    return false;
}
 

Leave a Reply

Your email address will not be published. Required fields are marked *

 

 

 

Theme by HermesThemes

Copyright © 2018 CoderzHeaven. All Rights Reserved

Please wait...

Subscribe to our newsletter

Want to be notified when our article is published? Enter your email address and name below to be the first to know.