package com.example.alarm07;

import android.app.AlarmManager;
import android.app.IntentService;
import android.app.PendingIntent;
import android.content.Context;
import android.content.Intent;
import android.content.IntentFilter;
import android.database.Cursor;


public class AlarmService extends IntentService 
{
	
	private static final String TAG = "AlarmService";
	
	public static final String POPULATE = "POPULATE";
	public static final String CREATE = "CREATE";
	public static final String CANCEL = "CANCEL";
	
	private IntentFilter matcher;

	public AlarmService() 
	{
		super(TAG);
		matcher = new IntentFilter();
		matcher.addAction(POPULATE);
		matcher.addAction(CREATE);
		matcher.addAction(CANCEL);
	}

	@Override
	protected void onHandleIntent(Intent intent) 
	{
		
		Intent i;
		PendingIntent pi;				
		AlarmManager am = (AlarmManager) getSystemService(Context.ALARM_SERVICE);
		
		i = new Intent(this, AlarmReceiver.class);
		
		pi = PendingIntent.getBroadcast(this, 0, i, PendingIntent.FLAG_UPDATE_CURRENT);
		
		am.setRepeating(AlarmManager.RTC_WAKEUP, System.currentTimeMillis(), 1000 * 5 , pi); 
		// //am.setRepeating(AlarmManager.RTC_WAKEUP, triggerAtTime, interval, operation);
	    
	}

	
	
}
