package com.example.patrice.rerservation01.service_alarm;

import android.app.AlarmManager;
import android.app.IntentService;
import android.app.PendingIntent;
import android.content.Context;
import android.content.Intent;
import android.util.Log;
import android.widget.Toast;


public class boot_alarm_service extends IntentService
{

    private static final String TAG = "boot_alarm_service";

    public boot_alarm_service()
    {
        super(TAG);
    }

    @Override
    protected void onHandleIntent(Intent intent)
    {
        definir();
    }

    public void definir()
    {
        Intent i;
        int s = 60;
        int keycode = 1;

        AlarmManager am = (AlarmManager) getSystemService(Context.ALARM_SERVICE);

        i = new Intent(this, boot_alarm_receiver.class);

        PendingIntent pi = PendingIntent.getBroadcast( this, 0, i, PendingIntent.FLAG_UPDATE_CURRENT);
//        pi =               PendingIntent.getBroadcast(this, (int) keycode, i, PendingIntent.FLAG_UPDATE_CURRENT);

        am.set(AlarmManager.RTC_WAKEUP, System.currentTimeMillis(), pi); // now
        am.setRepeating(AlarmManager.RTC_WAKEUP, System.currentTimeMillis(), (s * 1000), pi);

        Log.v("*********", "BOOT  alarm manager settings");
        Toast.makeText(boot_alarm_service.this, "BOOT alarm manager settings ..", Toast.LENGTH_LONG).show();

    }

}
