package com.nbusy.app;

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

public class DeviceBootBroadcastReceiver extends BroadcastReceiver {
    @Override
    public void onReceive(Context context, Intent intent) {
        if (intent.getAction().equals(Intent.ACTION_BOOT_COMPLETED)) {
            Intent serviceIntent = new Intent(context, WorkerService.class);
            serviceIntent.putExtra(WorkerService.STARTED_BY, DeviceBootBroadcastReceiver.class.getSimpleName());
            context.startService(serviceIntent);
        }
    }
}

@@ -575,16 +575,1311 @@
 Intent);
+%0A%0A            // todo: use WakefulBroadcastReceiver.startWakefulService() instead to make sure that device does not sleep while service is running?%0A//            /**%0A//             * This %7B@code WakefulBroadcastReceiver%7D takes care of creating and managing a partial wake lock for your app. It passes off the work of%0A//             * processing the GCM message to an %7B@code IntentService%7D, while ensuring that the device does not go back to sleep in the transition.%0A//             * The %7B@code IntentService%7D calls %7B@code GcmBroadcastReceiver.completeWakefulIntent()%7D when it is ready to release the wake lock.%0A//             */%0A//            public class GcmBroadcastReceiver extends WakefulBroadcastReceiver %7B%0A//%0A//                @Override%0A//                public void onReceive(Context context, Intent intent) %7B%0A//                    // explicitly specify that GcmIntentService will handle the intent%0A//                    ComponentName comp = new ComponentName(context.getPackageName(), GcmIntentService.class.getName());%0A//%0A//                    // start the service, keeping the device awake while it is launching%0A//                    startWakefulService(context, (intent.setComponent(comp)));%0A//                    setResultCode(Activity.RESULT_OK);%0A//                %7D%0A//            %7D
 %0A       

add WakefulBroadcastReceiver for boot broadcast receiver