Android——显示当前运行所有服务,判断服务是否运行
1.显示系统当前所有运行服务:
ActivityManager am = (ActivityManager) MainActivity.this.getSystemService(Context.ACTIVITY_SERVICE);
for (RunningServiceInfo service : am.getRunningServices(Integer.MAX_VALUE)) {
System.out.println(service.service.getPackageName()+"-----"+service.service.getClassName());
}
2.判断某一个服务是否运行:
public static boolean checkServiceStatus(Context context) {
boolean isServiceRunning = false;
ActivityManager am = (ActivityManager) context
.getSystemService(Context.ACTIVITY_SERVICE);
for (RunningServiceInfo service : am
.getRunningServices(Integer.MAX_VALUE)) {
if (BackgroundService.class.getName().equals(service.service.getClassName())) {
isServiceRunning = true;
break;
}
}
return isServiceRunning;
}
Android——显示当前运行所有服务,判断服务是否运行的更多相关文章
- android如何判断服务是否正在运行状态
如何检查后台服务(Android的Service类)是否正在运行?我希望我的Activity能够显示Service的状态,然后我可以打开或者关闭它. /** * 判断服务是否处于运行状态. * @pa ...
- Android之后台服务判断本应用Activity是否处于栈顶
在Android开发中,我们经常想知道是否自己的服务处于后台运行中,因为在后台运行的服务器优先级会降低,也就极有可能会被系统给回收掉,有什么好办法呢?Google推荐我们将服务运行到前台,如何知道服务 ...
- ServiceStatusUtils判断服务是否运行
import android.app.ActivityManager; import android.app.Service; import android.content.Context; impo ...
- android判断服务是否是运行状态
/** * 判断服务是否处于运行状态. * @param servicename * @param context * @return */ public static boolean isServi ...
- linux中 shell编程 判断服务是否运行
判断nginx是否运行中: if ps -ef|grep "nginx"|egrep -v grep >/dev/null then echo ok! else echo n ...
- Android开发-API指南-Bound 类型的服务
Bound Services 英文原文:http://developer.android.com/guide/components/bound-services.html 采集(更新)日期:2014- ...
- WCF心跳判断服务端及客户端是否掉线并实现重连接
WCF心跳判断服务端及客户端是否掉线并实现重连接 本篇文章将通过一个实例实现对WCF中针对服务端以及客户端是否掉线进行判断:若掉线时服务器或客户端又在线时将实现自动重连:将通过WCF的双工知识以及相应 ...
- Android Service总结04 之被绑定的服务 -- Bound Service
Android Service总结04 之被绑定的服务 -- Bound Service 版本 版本说明 发布时间 发布人 V1.0 添加了Service的介绍和示例 2013-03-17 Skywa ...
- Android Service总结03 之被启动的服务 -- Started Service
Android Service总结03 之被启动的服务 -- Started Service 版本 版本说明 发布时间 发布人 V1.0 添加了Service的介绍和示例 2013-03-17 Sky ...
- 【转】 Pro Android学习笔记(七七):服务(2):Local Service
目录(?)[-] Local service代码 调用Local ServiceLocal Service client代码 AndroidManifestxml定义Serviceacitivty的l ...
随机推荐
- iOS开发——百度地图SDK集成
(正在形成文档,待更新……)
- Xcode7 Xcode6 中添加pch文件
在Xcode7 和 Xcode6 中添加.pch文件是一样的,具体操作图文如下: 第一步:在Xcode的项目里,一般在Supporting Files 文件夹下创建,选中Supporting File ...
- 解码一个加密的js文件
<!DOCTYPE html><html lang="en"><head> <meta charset="UTF-8" ...
- Java 的自动装箱拆箱
Java 是面向对象的语言,其基本数据类型也就有了相对应的类,称为包装类.以下是基本数据类型对应的包装类: 基本数据类型 包装类 byte(1字节) Byte short(2字节) Short int ...
- linux - Mysql 创建用户和授权
CREATE USER 'cui'@'%' IDENTIFIED BY 'xxxxxxxxxxxxxxxxxx'; GRANT ALL ON test_db.* TO 'cui'@'%'; REVOK ...
- rpm命令详解
http://www.rpm.org/max-rpm/s1-rpm-install-additional-options.html#S2-RPM-INSTALL-REPLACEFILES-OPTION ...
- utf8转为gb2312的函数
from:http://blog.csdn.net/qianguozheng/article/details/46429245 // 代码转换操作类 class CodeConverter { pri ...
- C# Linq To DataTable 分组统计 DEMO
DataTable dt = SQLLayer.Get工作量统计(beginDate, endDate); var querySum = from t in dt.AsEnum ...
- Linux之C编译器gcc和makefile使用简介
使用gcc编译程序是,其过程主要分为四个阶段:预处理,编译,汇编,连接 程序清单: #include<stdio.h> #include<stdlib.h> int main( ...
- [DevExpress][TreeList]节点互斥
关键代码: /// <summary> /// 节点互斥同步 /// 说明 /// eg: ///TreeListNode _node = e.Node; ///_node.SyncMut ...