Check Service在kitkat的后台运行

时间:2017-08-09 12:43:16

标签: java android android-4.4-kitkat

此代码在所有版本中都运行良好,但我遇到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

0 个答案:

没有答案