当前位置: 首页>>代码示例>>Java>>正文


Java ActivityManager.RunningServiceInfo方法代码示例

本文整理汇总了Java中android.app.ActivityManager.RunningServiceInfo方法的典型用法代码示例。如果您正苦于以下问题:Java ActivityManager.RunningServiceInfo方法的具体用法?Java ActivityManager.RunningServiceInfo怎么用?Java ActivityManager.RunningServiceInfo使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在android.app.ActivityManager的用法示例。


在下文中一共展示了ActivityManager.RunningServiceInfo方法的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。

示例1: isMyServiceRunning

import android.app.ActivityManager; //导入方法依赖的package包/类
private boolean isMyServiceRunning(Class<?> serviceClass) {
    ActivityManager manager = (ActivityManager) getSystemService(Context.ACTIVITY_SERVICE);
    if (manager != null) {
        for (ActivityManager.RunningServiceInfo service : manager.getRunningServices(Integer.MAX_VALUE)) {
            if (serviceClass.getName().equals(service.service.getClassName())) return true;
        }
    }
    return false;
}
 
开发者ID:dhbw-timetable,项目名称:dhbw-timetable-android,代码行数:10,代码来源:MainActivity.java

示例2: onCreate

import android.app.ActivityManager; //导入方法依赖的package包/类
@Override
public void onCreate() {
    mAm = (ActivityManager) getSystemService(Context.ACTIVITY_SERVICE);

    // catch up in case we crashed but other processes are still running
    List<ActivityManager.RunningServiceInfo> svcs = mAm.getRunningServices(256);
    for (ActivityManager.RunningServiceInfo svc : svcs) {
        if (svc.service.getPackageName().equals(getPackageName())) {
            Log.v(TAG, "discovered running service: " + svc.process + " (" + svc.pid + ")");
            startTrackingProcess(svc.pid, svc.process,
                    System.currentTimeMillis() - (SystemClock.elapsedRealtime() - svc.activeSince));
        }
    }

    List<ActivityManager.RunningAppProcessInfo> procs = mAm.getRunningAppProcesses();
    for (ActivityManager.RunningAppProcessInfo proc : procs) {
        final String pname = proc.processName;
        if (pname.startsWith(getPackageName())) {
            Log.v(TAG, "discovered other running process: " + pname + " (" + proc.pid + ")");
            startTrackingProcess(proc.pid, pname, System.currentTimeMillis());
        }
    }
}
 
开发者ID:michelelacorte,项目名称:FlickLauncher,代码行数:24,代码来源:MemoryTracker.java

示例3: isServiceRunning

import android.app.ActivityManager; //导入方法依赖的package包/类
/**
 * 判断service是否正在运行
 *
 * @param mContext
 * @param className
 * @return
 */
public static boolean isServiceRunning(Context mContext, String className)
{

    boolean isRunning = false;
    ActivityManager activityManager = (ActivityManager)mContext.getSystemService(Context.ACTIVITY_SERVICE);
    List<ActivityManager.RunningServiceInfo> serviceList = activityManager.getRunningServices(200);

    if (!(serviceList.size() > 0))
    {
        return false;
    }


    for (int i = 0; i < serviceList.size(); i++)
    {
        if (serviceList.get(i).service.getClassName().equals(className) == true)
        {
            isRunning = true;
            break;
        }
    //  Log.d("Service:", "isServiceRunning: "+serviceList.get(i).service.getClassName());

    }
    return isRunning;
}
 
开发者ID:zhuyu1022,项目名称:amap,代码行数:33,代码来源:SystemUtils.java

示例4: getServices

import android.app.ActivityManager; //导入方法依赖的package包/类
@Override
public VParceledListSlice<ActivityManager.RunningServiceInfo> getServices(int maxNum, int flags, int userId) {
    synchronized (mHistory) {
        List<ActivityManager.RunningServiceInfo> services = new ArrayList<>(mHistory.size());
        for (ServiceRecord r : mHistory) {
            if (r.process.userId != userId) {
                continue;
            }
            ActivityManager.RunningServiceInfo info = new ActivityManager.RunningServiceInfo();
            info.uid = r.process.vuid;
            info.pid = r.process.pid;
            ProcessRecord processRecord = findProcessLocked(r.process.pid);
            if (processRecord != null) {
                info.process = processRecord.processName;
                info.clientPackage = processRecord.info.packageName;
            }
            info.activeSince = r.activeSince;
            info.lastActivityTime = r.lastActivityTime;
            info.clientCount = r.getClientCount();
            info.service = ComponentUtils.toComponentName(r.serviceInfo);
            info.started = r.startId > 0;
            services.add(info);
        }
        return new VParceledListSlice<>(services);
    }
}
 
开发者ID:coding-dream,项目名称:TPlayer,代码行数:27,代码来源:VActivityManagerService.java

示例5: isMyServiceRunning

import android.app.ActivityManager; //导入方法依赖的package包/类
public static boolean isMyServiceRunning(Context context, Class<?> serviceClass) {
    ActivityManager manager = (ActivityManager) context.getSystemService(Context.ACTIVITY_SERVICE);
    for (ActivityManager.RunningServiceInfo service : manager.getRunningServices(Integer.MAX_VALUE)) {
        if (serviceClass.getName().equals(service.service.getClassName())) {
            return true;
        }
    }
    return false;
}
 
开发者ID:squareboat,项目名称:Excuser,代码行数:10,代码来源:Utils.java

示例6: isRunning

import android.app.ActivityManager; //导入方法依赖的package包/类
/**
 * 判断服务是否正在运行
 * @param context
 * @param serviceName  服务的全类名
 * @return
 */
public static boolean isRunning(Context context, String serviceName) {
    // ActivityManager 进程的管理者
    ActivityManager am = (ActivityManager) context.getSystemService(Context.ACTIVITY_SERVICE);
    List<ActivityManager.RunningServiceInfo> runningServices = am.getRunningServices(1000); // 参数
    for (ActivityManager.RunningServiceInfo info : runningServices) {
        String className = info.service.getClassName();
        if (serviceName.equals(className)) {
            return true;
        }
    }
    return false;
}
 
开发者ID:A-Miracle,项目名称:QiangHongBao,代码行数:19,代码来源:ServiceUtils.java

示例7: isMyServiceRunning

import android.app.ActivityManager; //导入方法依赖的package包/类
public static boolean isMyServiceRunning(Class<?> serviceClass, Context context) {
    ActivityManager manager = (ActivityManager) context.getSystemService(Context.ACTIVITY_SERVICE);
    for (ActivityManager.RunningServiceInfo service : manager.getRunningServices(Integer.MAX_VALUE)) {
        if (serviceClass.getName().equals(service.service.getClassName())) {
            return true;
        }
    }
    return false;
}
 
开发者ID:theblixguy,项目名称:AutoScrollr,代码行数:10,代码来源:Utils.java

示例8: isServiceRunning

import android.app.ActivityManager; //导入方法依赖的package包/类
public static boolean isServiceRunning(Class<?> serviceClass, Context context) {
    ActivityManager manager = (ActivityManager) context.getSystemService(Context.ACTIVITY_SERVICE);
    for (ActivityManager.RunningServiceInfo service : manager.getRunningServices(Integer.MAX_VALUE)) {
        if (serviceClass.getName().equals(service.service.getClassName())) {
            return true;
        }
    }
    return false;
}
 
开发者ID:morogoku,项目名称:MTweaks-KernelAdiutorMOD,代码行数:10,代码来源:Utils.java

示例9: isMyServiceRunning

import android.app.ActivityManager; //导入方法依赖的package包/类
/**
 * Function to check service running of not
 *
 * @param context      Application context
 * @param serviceClass Service class
 * @return Service running or not
 */
public static boolean isMyServiceRunning(Context context, Class<?> serviceClass) {

    ActivityManager manager = (ActivityManager) context.getSystemService(Context.ACTIVITY_SERVICE);
    for (ActivityManager.RunningServiceInfo service : manager
            .getRunningServices(Integer.MAX_VALUE)) {
        if (serviceClass.getName().equals(service.service.getClassName())) {
            return true;
        }
    }
    return false;
}
 
开发者ID:fekracomputers,项目名称:QuranAndroid,代码行数:19,代码来源:Settingsss.java

示例10: isServiceRunning

import android.app.ActivityManager; //导入方法依赖的package包/类
private boolean isServiceRunning(Class<LocationData> locationDataClass) {
    ActivityManager manager = (ActivityManager) getContext().getSystemService(Context.ACTIVITY_SERVICE);
    for (ActivityManager.RunningServiceInfo service : manager.getRunningServices(Integer.MAX_VALUE)) {
        if (locationDataClass.getName().equals(service.service.getClassName())) {
            return true;
        }
    }
    return false;
}
 
开发者ID:picopalette,项目名称:event-me,代码行数:10,代码来源:ProfileFragment.java

示例11: isMyServiceRunning

import android.app.ActivityManager; //导入方法依赖的package包/类
private boolean isMyServiceRunning(Class<?> serviceClass) {
    ActivityManager manager = (ActivityManager) getActivity().getSystemService(Context.ACTIVITY_SERVICE);
    for (ActivityManager.RunningServiceInfo service : manager.getRunningServices(Integer.MAX_VALUE)) {
        if (serviceClass.getName().equals(service.service.getClassName())) {
            return true;
        }
    }
    return false;
}
 
开发者ID:jonathansautter,项目名称:AutoOff,代码行数:10,代码来源:Time_Fragment.java

示例12: isServiceRunning

import android.app.ActivityManager; //导入方法依赖的package包/类
/**
 * Method to check if the service to get location is already running
 *
 * @param context      - Used to access the System services
 * @param serviceClass - Class that has to be checked if its instance is running
 * @return - boolean on success
 */
public static boolean isServiceRunning(Context context, Class<?> serviceClass) {
    ActivityManager manager = (ActivityManager) context.getSystemService(Context.ACTIVITY_SERVICE);
    for (ActivityManager.RunningServiceInfo service : manager.getRunningServices(Integer.MAX_VALUE)) {
        if (serviceClass.getName().equals(service.service.getClassName())) {
            return true;
        }
    }
    return false;
}
 
开发者ID:dilipkumar4813,项目名称:LocationTracking,代码行数:17,代码来源:MapsUtils.java

示例13: isWorking

import android.app.ActivityManager; //导入方法依赖的package包/类
public boolean isWorking() {
    ActivityManager manager = (ActivityManager) context.getSystemService(Context.ACTIVITY_SERVICE);
    String serviceName = DNSService.class.getName();
    for (ActivityManager.RunningServiceInfo service : manager.getRunningServices(Integer.MAX_VALUE)) {
        if (serviceName.equals(service.service.getClassName())) {
            return true;
        }
    }
    return false;
}
 
开发者ID:msayan,项目名称:star-dns-changer,代码行数:11,代码来源:DNSPresenter.java

示例14: onDestroy

import android.app.ActivityManager; //导入方法依赖的package包/类
@Override
protected void onDestroy() {
    ActivityManager manager = (ActivityManager) getSystemService(Context.ACTIVITY_SERVICE);
    for (ActivityManager.RunningServiceInfo service : manager.getRunningServices(Integer.MAX_VALUE)) {
        if (CacheService.class.getName().equals(service.service.getClassName())) {
            stopService(new Intent(this, CacheService.class));
        }
    }
    super.onDestroy();
}
 
开发者ID:makezhao,项目名称:LianXiZhihu,代码行数:11,代码来源:MainActivity.java

示例15: isMyServiceRunning

import android.app.ActivityManager; //导入方法依赖的package包/类
private boolean isMyServiceRunning(Class<?> serviceClass) {
    ActivityManager manager = (ActivityManager) getSystemService(Context.ACTIVITY_SERVICE);
    for (ActivityManager.RunningServiceInfo service : manager.getRunningServices(Integer.MAX_VALUE)) {
        if (serviceClass.getName().equals(service.service.getClassName())) {
            return true;
        }
    }
    return false;
}
 
开发者ID:atareao,项目名称:InstaShare,代码行数:10,代码来源:MainActivity.java


注:本文中的android.app.ActivityManager.RunningServiceInfo方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。