您的位置:首页 > 其它

检查进程是否在运行

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) {
}
内容来自用户分享和网络整理,不保证内容的准确性,如有侵权内容,可联系管理员处理 点击这里给我发消息
标签: