package com.qiscus.sdk.chat.core.util;

import android.app.ActivityManager;
import android.content.Context;

import com.qiscus.sdk.chat.core.QiscusCore;
import com.qiscus.sdk.chat.core.service.QiscusSyncJobService;
import com.qiscus.sdk.chat.core.service.QiscusSyncService;

public class QiscusServiceUtil {

    private QiscusServiceUtil() {

    }

    public static boolean isMyServiceRunning() {
        Class<?> serviceClass;
        if (BuildVersionUtil.isOreoLower()) {
            serviceClass = QiscusSyncService.class;
        } else {
            serviceClass = QiscusSyncJobService.class;
        }
        ActivityManager manager = (ActivityManager) QiscusCore.getApps().getApplicationContext().getSystemService(Context.ACTIVITY_SERVICE);
        for (ActivityManager.RunningServiceInfo service : manager.getRunningServices(Integer.MAX_VALUE)) {
            if (serviceClass.getName().equals(service.service.getClassName())) {
                return true;
            }
        }
        return false;
    }
}

@@ -745,16 +745,51 @@
 RVICE);%0A
+        if (manager != null) %7B%0A    
         
@@ -883,24 +883,28 @@
 X_VALUE)) %7B%0A
+    
             
@@ -984,24 +984,28 @@
             
+    
 return true;
@@ -1005,16 +1005,34 @@
 n true;%0A
+                %7D%0A
         

add checker ! = null for ActivityManager