package com.tumbleweed.riseshine;

import android.content.BroadcastReceiver;
import android.content.Context;
import android.content.Intent;
import android.os.PowerManager;
import android.os.SystemClock;
import android.widget.Toast;

public class RiseShineAlarm extends BroadcastReceiver
{
    @Override
    public void onReceive(Context context, Intent intent)
    {
    	

    	//make sure we wake up from asleep

    	PowerManager pm = (PowerManager) context.getSystemService(Context.POWER_SERVICE);
    	pm.userActivity(SystemClock.uptimeMillis(), false);
    	if(SatanAlarm.wl!=null)
    	{
    		SatanAlarm.wl.release();
    		SatanAlarm.wl = null;
    	}
    	SatanAlarm.wl = pm.newWakeLock(PowerManager.PARTIAL_WAKE_LOCK | PowerManager.ACQUIRE_CAUSES_WAKEUP, "My Tag");
    	SatanAlarm.wl.acquire();





    	//start the activity that makes alarm noise, etc.
    	Intent intentStart = new Intent(context,SatanAlarm.class);
    	intentStart.addFlags(Intent.FLAG_ACTIVITY_NEW_TASK);
    	context.startActivity(intentStart);


        
    } 
   
}
