博客
关于我
强烈建议你试试无所不能的chatGPT,快点击我
判断Service是否在运行
阅读量:6859 次
发布时间:2019-06-26

本文共 741 字,大约阅读时间需要 2 分钟。

private boolean isServiceRunning() {
ActivityManager manager = (ActivityManager) getSystemService(ACTIVITY_SERVICE); for (ActivityManager.RunningServiceInfo service : manager.getRunningServices(Integer.MAX_VALUE)) {
if ("com.baidu.location.service.MyLocationService".equals(service.service.getClassName())) {
return true; } } return false; } @Override
protected void onStart() {
// TODO Auto-generated method stub super.onStart(); if(this.isServiceRunning()){
startLocation.setText(getString(R.string.stoplocation)); }else{
startLocation.setText(getString(R.string.startlocation)); }
}

转载地址:http://ndxyl.baihongyu.com/

你可能感兴趣的文章
小谈业务应用架构
查看>>
JWPlayer Uncaught Error: Invalid SRT file
查看>>
mysql使用GROUP BY分组实现取前N条记录的方法
查看>>
web项目log日志查看分析->流程理解
查看>>
无线路由器连接电信光猫实现拨号上网方法
查看>>
nyoj 题目10 skiing —— 南阳oj
查看>>
Cocos2d-x游戏《雷电大战》开源啦!要源代码要资源快快来~~
查看>>
C++中的链式操作
查看>>
CNAME记录和A记录
查看>>
【Hibernate】(2)Hibernate配置与session、transaction
查看>>
POJ 2823 Sliding Window 单调队列
查看>>
yii 邮箱封装
查看>>
浅谈UI自动化测试
查看>>
认证模式之Spnego模式
查看>>
对象逆序列化报错:java.lang.ClassNotFoundException
查看>>
iOS - UITableView加载网络图片 cell适应图片高度
查看>>
DocFX生成PDF文档
查看>>
运营活动需求实现
查看>>
代理(Proxy)和反射(Reflection)
查看>>
隐藏当前Activity而不关闭
查看>>