package com.example.service04;



import java.io.File;
import java.io.FileOutputStream;
import java.io.IOException;

import android.app.Notification;
import android.app.NotificationManager;
import android.app.PendingIntent;
import android.content.BroadcastReceiver;
import android.content.Context;
import android.content.Intent;
import android.net.Uri;
import android.os.Environment;
import android.content.BroadcastReceiver;
import android.content.Context;
import android.content.Intent;
import android.widget.Toast;


public class Receiver extends BroadcastReceiver 
{
	
//	private static final String TAG = "AlarmReceiver";

	@Override
	public void onReceive(Context context, Intent intent) 
	{
		int alarmId = intent.getIntExtra("valeur", -1);
		//Toast.makeText(context, "Alarm received!", Toast.LENGTH_LONG).show();	
		
		
		if(alarmId == 251)
		{
			Toast.makeText(context, "Alarm 1111", Toast.LENGTH_SHORT).show();
			
		}
		
		if(alarmId == 255)
		{
			Toast.makeText(context, "Alarm 2222", Toast.LENGTH_SHORT).show();
			
		}
		/*
		String content = "hello";
		File file;
		FileOutputStream outputStream;
		try 
		{
		    file = new File(Environment.getExternalStorageDirectory(), "trace_file.txt");
		 
		    outputStream = new FileOutputStream(file);
		    outputStream.write(content.getBytes());
		    outputStream.close();
		} 
		catch (IOException e) 
		{
		    e.printStackTrace();
		}
		
		//Toast.makeText(context, "Alarm received!", Toast.LENGTH_LONG).show();
		//Notification n = new Notification(R.drawable.ic_launcher, "Debug trace", System.currentTimeMillis());
		//PendingIntent pi = PendingIntent.getActivity(context, 0, new Intent(), 0);
		//n.setLatestEventInfo(context, "Remind Me", "Debug trace", pi);		
		//n.flags |= Notification.FLAG_AUTO_CANCEL;		
		//NotificationManager nm = (NotificationManager) context.getSystemService(Context.NOTIFICATION_SERVICE);
		//nm.notify(100, n);*/
		
		
	}
}	





