/**
*	AlarmTask.java
*
*	@author Johan
*/

package se.chalmers.watchme.notifications;

import java.util.Calendar;

import android.app.AlarmManager;
import android.app.PendingIntent;
import android.content.Context;
import android.content.Intent;

public class AlarmTask implements Runnable {
	
	private final Context ctx;
	private final Calendar date;
	private final AlarmManager manager;
	
	public AlarmTask(Context context, Calendar date) {
		// Get the Android alarm service
		this.manager = (AlarmManager) this.ctx.getSystemService(Context.ALARM_SERVICE);
				
		this.ctx = context;
		this.date = date;
	}
	
	public void run() {
		Intent intent = new Intent(this.ctx, NotifyService.class);
		intent.putExtra(NotifyService.INTENT_NOTIFY, true);
		
		PendingIntent pending = PendingIntent.getService(this.ctx, 0, intent, 0);
		
		this.manager.set(AlarmManager.RTC, this.date.getTimeInMillis(), pending);
	}

}

@@ -435,16 +435,61 @@
 date) %7B%0A
+%09%09this.ctx = context;%0A%09%09this.date = date;%0A%09%09%0A
 %09%09// Get
@@ -601,55 +601,8 @@
 E);%0A
-%09%09%09%09%0A%09%09this.ctx = context;%0A%09%09this.date = date;%0A
 %09%7D%0A%09

Fix null pointer bug