Android Open Source - eVent Deadline Tracker Service Task

From Project

Back to project page eVent.


The source code is released under:

Apache License

If you think the Android project eVent 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 com.example.maps;
//from  w ww . ja  v a2 s .c  om
import java.util.Collections;
import java.util.Date;
import java.util.Set;
import java.util.Calendar;

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

public class DeadlineTrackerServiceTask implements Runnable{

  private NotificationManager notificationManager;
  public static final String LOG_TAG = "MyService";
  private boolean running;
  private Context context;
  public ArrayOfEvents events;
  public void setEvents(ArrayOfEvents myEvents){
    events = myEvents;
    public DeadlineTrackerServiceTask(Context _context) {
      context = _context;      
      // Put here what to do at creation.
    public void run() {
      notificationManager = (NotificationManager) context.getSystemService(Context.NOTIFICATION_SERVICE);
        running = true;
        while (running) {
          // Sleep a tiny bit, the check the array
      try {
        Log.i("LOG_TAG", "Checking events");
        Calendar rightNow = Calendar.getInstance();
        for(int i = 0; i < events.eventsArray.size(); i++){
          Log.i("LOG_TAG", "loop " + i);
          if( events.eventsArray.get(i).notified == false && events.eventsArray.get(i).deadline.getTimeInMillis() < rightNow.getTimeInMillis() ){
            events.eventsArray.get(i).notified = true;
      } catch (Exception e) {
    //will create a notification when a deadline has been hit
  public void Notify(String title)
      Log.i("LOG_TAG", "Notifying");
    Notification notification = new Notification(
            title + " has hit its deadline",
    Intent notificationIntent = new Intent();
      PendingIntent pendingIntent = PendingIntent.getActivity(context, 0, notificationIntent, 0);
      notification.setLatestEventInfo(context, "Event Planner Notification",
          title + " has hit its deadline", pendingIntent);
    notificationManager.notify(1, notification);
    //restarts the service. Probably not necessary
    public void startThis()
      running = true;

  public void stopProcessing() {
    running = false;  


Java Source Code List