package com.ramos.munoz.tesis;

import java.util.Calendar;

import android.app.AlarmManager;
import android.app.PendingIntent;
import android.content.BroadcastReceiver;
import android.content.Context;
import android.content.Intent;
import android.widget.Toast;

public class BootReciever extends BroadcastReceiver {

    // Restart service every 30 seconds
    private static final long INTERVALO = 1000 * 30;

    @Override
    public void onReceive(Context context, Intent intent) {
	AlarmManager service = (AlarmManager) context.getSystemService(Context.ALARM_SERVICE);
	Intent i = new Intent(context, AlarmaReciever.class);
	PendingIntent pending = PendingIntent.getBroadcast(context, 0, i, PendingIntent.FLAG_CANCEL_CURRENT);
	Calendar cal = Calendar.getInstance();
	cal.add(Calendar.SECOND, 30);
	service.setInexactRepeating(AlarmManager.RTC_WAKEUP, cal.getTimeInMillis(), INTERVALO, pending);

    }

}
