Android Open Source - hts-cycle Alarm Receiver

From Project

Back to project page hts-cycle.


The source code is released under:

GNU General Public License

If you think the Android project hts-cycle listed in this page is inappropriate, such as containing malicious code/tools or violating the copyright, please email info at java2s dot com, thanks.

Java Source Code

package it.uniroma2.wifionoff;
//from   w w  w.  j a v a 2 s  .  c o  m

import java.text.SimpleDateFormat;
import java.util.Calendar;
import java.util.Date;

import android.content.BroadcastReceiver;
import android.content.Context;
import android.content.Intent;
import android.util.Log;

public class AlarmReceiver extends BroadcastReceiver {

  public void onReceive(Context context, Intent intent) {
    // TODO Auto-generated method stub
    long now=System.currentTimeMillis();
    Intent myService = new Intent(Setting.START);
        String time="";
        Integer t=30;
        time= (intent.getCharSequenceExtra("alarm_time")).toString();
      // add 5 minutes to the calendar object

//        Intent next = new Intent(context, AlarmReceiver.class);
//        next.putExtra("alarm_time", time);
//        // In reality, you would want to have a static variable for the request code instead of 192837
//        PendingIntent sender = PendingIntent.getBroadcast( context, 192837, next, PendingIntent.FLAG_UPDATE_CURRENT);
//        // Get the AlarmManager service
//        long yourmilliseconds = now + (t*1000) ;
//        SimpleDateFormat sdf = new SimpleDateFormat("MMM dd,yyyy HH:mm:ss");
//        Date resultdate = new Date(yourmilliseconds);
//        System.out.println(sdf.format(resultdate));
//        AlarmManager am = (AlarmManager) context.getSystemService(Service.ALARM_SERVICE);
//        am.set(AlarmManager.RTC_WAKEUP, now + (t*1000) , sender);

      // add 5 minutes to the timeoutendar object



Java Source Code List