is System Update Service Running - Android Android OS

Android examples for Android OS:Service

Description

is System Update Service Running

Demo Code


//package com.java2s;
import java.util.List;

import android.app.ActivityManager;
import android.app.ActivityManager.RunningServiceInfo;
import android.content.Context;

public class Main {
    public static boolean isSystemUpdateServiceRunning(Context context,
            String serviceName) {
        ActivityManager activityManager = (ActivityManager) context
                .getSystemService(Context.ACTIVITY_SERVICE);
        List<RunningServiceInfo> serviceInfo = activityManager
                .getRunningServices(100);
        for (RunningServiceInfo info : serviceInfo) {
            String name = info.service.getClassName();
            if (name.equals(serviceName)) {
                // serviceName example
                // "com.sumavision.talktv.services.SystemUpdateService"
                return true;
            }/*from   w  w w  .jav a  2 s  . co  m*/
        }
        return false;

    }
}

Related Tutorials