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));
}

}

相关文章:

  • 2022-12-23
  • 2022-12-23
  • 2022-03-03
  • 2022-12-23
  • 2022-12-23
  • 2022-12-23
  • 2022-12-23
猜你喜欢
  • 2021-08-25
  • 2021-11-05
  • 2022-12-23
  • 2021-07-17
  • 2021-06-04
  • 2021-11-28
相关资源
相似解决方案