package com.tom_e_white.chickenalerts;

import android.app.Notification;
import android.app.NotificationManager;
import android.content.BroadcastReceiver;
import android.content.Context;
import android.content.Intent;
import android.media.MediaPlayer;

public class ChickenAlertReceiver extends BroadcastReceiver {
	@Override
	public void onReceive(Context context, Intent intent) {
		Notification notification = new Notification.Builder(context)
				.setContentTitle("Chicken Alert")
				.setContentText("Have you put the chickens to bed?")
				.setTicker("Have you put the chickens to bed?")
				.setSmallIcon(R.drawable.ic_launcher).build();
		notification.flags |= Notification.FLAG_AUTO_CANCEL;
		NotificationManager notificationManager = (NotificationManager) context
				.getSystemService(Context.NOTIFICATION_SERVICE);
		notificationManager.notify(0, notification);
		
		MediaPlayer mediaPlayer = MediaPlayer.create(context, R.raw.cluck);
		mediaPlayer.start(); // no need to call prepare(); create() does that for you
	}

}
@@ -244,16 +244,71 @@
 aPlayer;
+%0Aimport android.media.MediaPlayer.OnCompletionListener;
 %0A%0Apublic
@@ -1021,65 +1021,209 @@
 t();
- // no need to call prepare(); create() does that for you
+%0A%09%09mediaPlayer.setOnCompletionListener(new OnCompletionListener() %7B%0A%09        @Override%0A%09        public void onCompletion(MediaPlayer mp) %7B%0A%09            mp.release();                %0A%09        %7D%0A%09    %7D);
 %0A%09%7D%0A

Stop media player after sound.