package com.nyaruka.sigtrac;

import android.content.BroadcastReceiver;
import android.content.Context;
import android.content.Intent;
import android.util.Log;

public class BootReceiver extends BroadcastReceiver {


    @Override
    public void onReceive(Context context, Intent intent) {
        context.startService(new Intent(context, PingService.class));
    }
}

@@ -23,16 +23,52 @@
 gtrac;%0A%0A
+import android.app.ActivityManager;%0A
 import a
@@ -97,24 +97,24 @@
 stReceiver;%0A
-
 import andro
@@ -332,68 +332,824 @@
     
-context.startService(new Intent(context, PingService.class))
+ checkService(context);%0A    %7D%0A%0A%0A    public static boolean checkService(Context context)%7B%0A        if(!isServiceRunning(context))%7B%0A            startService(context);%0A            return false;%0A        %7D else %7B%0A            return true;%0A        %7D%0A    %7D%0A%0A%0A    private static void startService(Context context)%7B%0A        context.startService(new Intent(context, PingService.class));%0A    %7D%0A%0A%0A    private static boolean isServiceRunning(Context context) %7B%0A        ActivityManager manager = (ActivityManager) context.getSystemService(Context.ACTIVITY_SERVICE);%0A        for (ActivityManager.RunningServiceInfo service : manager.getRunningServices(Integer.MAX_VALUE)) %7B%0A            if (PingService.class.getName().equals(service.service.getClassName())) %7B%0A                return true;%0A            %7D%0A        %7D%0A        return false
 ;%0A  

check that the service is not running before running it