检查进程是否在运行
2016-06-12 16:15
225 查看
String pid = String.format("/proc/%s", pId); File pidFile = new File(pid); boolean active = pidFile.exists();
如果不存在,可以通过如下方法启动服务。下面需要引用innerClass或者通过反射方法调用
IActivityManager am = ActivityManagerNative.getDefault();Method method = null;try {// Build.SDK_INT >= 17method = am.getClass().getMethod("startService",IApplicationThread.class, Intent.class, String.class,int.class);Object cn = method.invoke(am, null, intent, intent.getType(), 0);KLog.d(TAG, "start service return: " + cn);} catch (NoSuchMethodException e) {
}
相关文章推荐
- Background Modeling and Foreground Detection -- SOBS
- Android ramdisk.img system.img userdata.img介绍与使用
- XML解析——Java中XML的四种解析方式
- 学习笔记之高质量C++/C编程指南
- 让我们从0开始 知识_1
- 在qtcreate设计器中添加菜单以及添加动作
- 秒转为时分秒的oracle函数
- Android 6.0 运行时权限处理完全解析
- Servlet什么时候被初始化
- RESTful API 设计指南
- yii2嵌入微信公众号支付
- 【水果大全】快看,你属于哪种水果身材?
- solution Of 1104. Sum of Number Segments (20)
- [leetcode] 106. Construct Binary Tree from Inorder and Postorder Traversal 解题报告
- 【EF】 更新条目时出错。有关详细信息,请参见内部异常。
- GDB调试
- 分析SIX锁和锁分区导致的死锁
- TIME-WAIT 快速回收
- UML关系总结
- 使用startForeground让android服务前台运行