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


Java ActivityManager.getRunningServices方法代码示例

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


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

示例1: isServiceRunning

import android.app.ActivityManager; //导入方法依赖的package包/类
/**
 * 用来判断服务是否运行.
 * @param mContext
 * @param className 判断的服务名字(例如:net.loonggg.testbackstage.TestService)
 * @return true 在运行 false 不在运行
 */
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(Integer.MAX_VALUE);
	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;
		}
	}
	return isRunning;
}
 
开发者ID:ebridfighter,项目名称:GongXianSheng,代码行数:24,代码来源:CommonUtils.java

示例2: IsServiceRunning

import android.app.ActivityManager; //导入方法依赖的package包/类
public boolean IsServiceRunning(@NonNull Class<?> serviceClass) {
    ActivityManager activityManager = (ActivityManager) _context.getSystemService(Context.ACTIVITY_SERVICE);

    if (activityManager == null) {
        Logger.getInstance().Error(TAG, "ActivityManager is null!");
        return false;
    }

    for (RunningServiceInfo service : activityManager.getRunningServices(Integer.MAX_VALUE)) {
        if (serviceClass.getName().equals(service.service.getClassName())) {
            return true;
        }
    }

    return false;
}
 
开发者ID:GuepardoApps,项目名称:LucaHome-AndroidApplication,代码行数:17,代码来源:AndroidSystemController.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: onReceive

import android.app.ActivityManager; //导入方法依赖的package包/类
@Override
public void onReceive(Context context, Intent arg1) {
   

	 ActivityManager manager = (ActivityManager)context.   getSystemService(Context.ACTIVITY_SERVICE);
	 for (RunningServiceInfo service : manager.getRunningServices(Integer.MAX_VALUE))
{

    if (digiPune.class.getName().equals(service.service.getClassName())) {
                        //running 
       }
   else{
  	 context.startService(new Intent(context, digiPune.class));
       }

}
}
 
开发者ID:SkylineLabs,项目名称:FindX,代码行数:18,代码来源:BootCompletedReceiver.java

示例5: isServiceWork

import android.app.ActivityManager; //导入方法依赖的package包/类
/**
 * 判断某个服务是否正在运行的方法
 *
 * @param mContext
 * @param serviceName 是包名+服务的类名
 * @return true代表正在运行,false代表服务没有正在运行
 */
public static boolean isServiceWork(Context mContext, String serviceName) {
    boolean isWork = false;
    ActivityManager myAM = (ActivityManager) mContext
            .getSystemService(Context.ACTIVITY_SERVICE);
    List<ActivityManager.RunningServiceInfo> myList = myAM.getRunningServices(40);
    if (myList.size() <= 0) {
        return false;
    }
    for (int i = 0; i < myList.size(); i++) {
        String mName = myList.get(i).service.getClassName().toString();
        if (mName.equals(serviceName)) {
            isWork = true;
            break;
        }
    }
    return isWork;
}
 
开发者ID:kaixuanluo,项目名称:pc-android-controller-android,代码行数:25,代码来源:ServiceManager.java

示例6: isMyServiceRunning2

import android.app.ActivityManager; //导入方法依赖的package包/类
private boolean isMyServiceRunning2(Class<NotificationService2> 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:MLNO,项目名称:airgram,代码行数:10,代码来源:LaunchActivity.java

示例7: serviceIsRunningInForeground

import android.app.ActivityManager; //导入方法依赖的package包/类
public boolean serviceIsRunningInForeground(Context context) {
    Log.d(TAG, "serviceIsRunningInForeground()");
    ActivityManager manager = (ActivityManager) context.getSystemService(Context.ACTIVITY_SERVICE);
    for (ActivityManager.RunningServiceInfo service : manager.getRunningServices(Integer.MAX_VALUE)) {
        if (getClass().getName().equals(service.service.getClassName())) {
            if (service.foreground) {
                Log.d(TAG, "serviceIsRunningInForeground() - It is");
                return true;
            }
        }
    }
    Log.d(TAG, "serviceIsRunningInForeground() - It is NOT");
    return false;
}
 
开发者ID:stefanonicolai,项目名称:AstronomyTourPadova,代码行数:15,代码来源:LocationService.java

示例8: getServiceInfo

import android.app.ActivityManager; //导入方法依赖的package包/类
private ActivityManager.RunningServiceInfo getServiceInfo() {
    ActivityManager manager = (ActivityManager) getContext().getSystemService(Context.ACTIVITY_SERVICE);
    List<ActivityManager.RunningServiceInfo> serviceInfoList = manager.getRunningServices(Integer.MAX_VALUE);
    for (ActivityManager.RunningServiceInfo service : serviceInfoList) {
        if (RemoteProcessService.class.getName().equals(service.service.getClassName())) {
            return service;
        }
    }
    return null;
}
 
开发者ID:weiwenqiang,项目名称:GitHub,代码行数:11,代码来源:RealmInterprocessTest.java

示例9: isMyServiceRunning

import android.app.ActivityManager; //导入方法依赖的package包/类
public boolean isMyServiceRunning(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:adityakamble49,项目名称:gofun-app,代码行数:12,代码来源:ServiceUtils.java

示例10: isMyServiceRunning

import android.app.ActivityManager; //导入方法依赖的package包/类
private boolean isMyServiceRunning(Class<LocationData> locationDataClass) {
    ActivityManager manager = (ActivityManager) 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,代码行数:11,代码来源:EventDisplayActivity.java

示例11: isScreenFilterServiceRunning

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

示例12: isRunning

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

示例13: 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:suhaas-livcd,项目名称:Android_Labs,代码行数:10,代码来源:ActivityService.java

示例14: isUpdating

import android.app.ActivityManager; //导入方法依赖的package包/类
private boolean isUpdating() {
	ActivityManager manager = (ActivityManager) getSystemService(ACTIVITY_SERVICE);
	for (RunningServiceInfo service : manager.getRunningServices(Integer.MAX_VALUE))
		if (UpdateService.class.getName().equals(service.service.getClassName()))
			return true;
	return false;
}
 
开发者ID:ukanth,项目名称:XPrivacy,代码行数:8,代码来源:ActivityBase.java

示例15: isServiceRunning

import android.app.ActivityManager; //导入方法依赖的package包/类
/**
 * 判断服务是否运行
 *
 * @param context   上下文
 * @param className 完整包名的服务类名
 * @return {@code true}: 是<br>{@code false}: 否
 */
public static boolean isServiceRunning(Context context, String className) {
    ActivityManager activityManager = (ActivityManager) context.getSystemService(Context.ACTIVITY_SERVICE);
    List<RunningServiceInfo> infos = activityManager.getRunningServices(0x7FFFFFFF);
    if (infos == null || infos.size() == 0) return false;
    for (RunningServiceInfo info : infos) {
        if (className.equals(info.service.getClassName())) return true;
    }
    return false;
}
 
开发者ID:angcyo,项目名称:RLibrary,代码行数:17,代码来源:ServiceUtils.java


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