Android Open Source - hts-cycle Alarm Receiver






From Project

Back to project page hts-cycle.

License

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.app.AlarmManager;
import android.app.PendingIntent;
import android.app.Service;
import android.content.BroadcastReceiver;
import android.content.Context;
import android.content.Intent;
import android.util.Log;

public class AlarmReceiver extends BroadcastReceiver {

  @Override
  public void onReceive(Context context, Intent intent) {
    // TODO Auto-generated method stub
    Log.w("Alarm","Start");
    long now=System.currentTimeMillis();
    
    Intent myService = new Intent(Setting.START);
      context.sendBroadcast(myService);
        String time="";
        Integer t=30;
        
      if(intent.hasExtra("alarm_time")){
        
        time= (intent.getCharSequenceExtra("alarm_time")).toString();
        t=Integer.parseInt(time);
        
        
      }
    
      // 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

it.uniroma2.musicsharep2p.DataBaseHelper.java
it.uniroma2.musicsharep2p.DefaultValue.java
it.uniroma2.musicsharep2p.DownloadActivity.java
it.uniroma2.musicsharep2p.MainActivity.java
it.uniroma2.musicsharep2p.MessengerService.java
it.uniroma2.musicsharep2p.MusicSettingActivity.java
it.uniroma2.musicsharep2p.MusicShutReceiver.java
it.uniroma2.musicsharep2p.PlayListActivity.java
it.uniroma2.musicsharep2p.RemoteServiceConnection.java
it.uniroma2.musicsharep2p.SongsManager.java
it.uniroma2.musicsharep2p.Utilities.java
it.uniroma2.wifionoff.AlarmReceiver.java
it.uniroma2.wifionoff.AppActivity.java
it.uniroma2.wifionoff.AppHelper.java
it.uniroma2.wifionoff.DataBaseHelper.java
it.uniroma2.wifionoff.IpMaker.java
it.uniroma2.wifionoff.MainActivity.java
it.uniroma2.wifionoff.MessageMaker.java
it.uniroma2.wifionoff.MyListActivity.java
it.uniroma2.wifionoff.NameActivity.java
it.uniroma2.wifionoff.OnOffService.java
it.uniroma2.wifionoff.PacketHandler.java
it.uniroma2.wifionoff.ServiceCall.java
it.uniroma2.wifionoff.SettingActivity.java
it.uniroma2.wifionoff.Setting.java
it.uniroma2.wifionoff.ShutDownReceiver.java
it.uniroma2.wifionoff.WifiConfigurationNew.java
it.uniroma2.wifionoff.WifiHandler.java
it.uniroma2.wifionoff.WifiManagerNew.java
it.uniroma2.wifionoff.WifiOffReceiver.java
it.uniroma2.wifionoff.WifiReceiver.java