此代码在所有版本中都运行良好,但我遇到KitKat问题
private boolean isMyServiceRunning(Class<?> serviceClass) {
ActivityManager manager = (ActivityManager) ToyotaFillActivity.this.getSystemService(Context.ACTIVITY_SERVICE);
for (ActivityManager.RunningServiceInfo service : manager.getRunningServices(Integer.MAX_VALUE)) {
Log.e("@@@Text1:",serviceClass.getName()+"@@@TEST2:"+service.service.getClassName());
if (serviceClass.getName().equals(service.service.getClassName())) {
System.out.println("Already Running");
return true;
}
}
System.out.println("false");
return false;
}
在kitkat中,这是返回false