Main.java Source code

Java tutorial

Introduction

Here is the source code for Main.java

Source

//package com.java2s;
//License from project: Apache License 

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

public class Main {
    public static ActivityManager.RunningServiceInfo getServiceInfo(Context context, Class<? extends Service> cls) {
        ActivityManager manager = (ActivityManager) context.getSystemService(Context.ACTIVITY_SERVICE);
        for (ActivityManager.RunningServiceInfo info : manager.getRunningServices(Integer.MAX_VALUE)) {
            if (cls.getName().equals(info.service.getClassName())) {
                return info;
            }
        }
        return null;
    }
}