Code example for WakefulBroadcastReceiver

import android.content.Intent; 
import android.os.SystemClock; 
import android.util.Log; 
public class SimpleWakefulReceiver extends WakefulBroadcastReceiver { 
    public void onReceive(Context context, Intent intent) {
        // This is the Intent to deliver to our service. 
        Intent service = new Intent(context, SimpleWakefulService.class);
        // Start the service, keeping the device awake while it is launching. 
        Log.i("SimpleWakefulReceiver", "Starting service @ " + SystemClock.elapsedRealtime());
        startWakefulService(context, service);