From: Petru Trimbitas Date: Tue, 18 Jun 2013 13:38:03 +0000 (+0300) Subject: Add function to add alarm X-Git-Url: http://git.ieval.ro/?a=commitdiff_plain;h=6f48b087593f6b58c98a0ef3721334c4f4d4b2f9;p=unical.git Add function to add alarm --- diff --git a/res/menu/event_list.xml b/res/menu/event_list.xml index 8d1346e..6a13736 100644 --- a/res/menu/event_list.xml +++ b/res/menu/event_list.xml @@ -10,5 +10,4 @@ android:icon="@android:drawable/ic_popup_sync" android:showAsAction="ifRoom"> - diff --git a/src/ro/ieval/unical/AlarmActivity.java b/src/ro/ieval/unical/AlarmActivity.java deleted file mode 100644 index 2868764..0000000 --- a/src/ro/ieval/unical/AlarmActivity.java +++ /dev/null @@ -1,19 +0,0 @@ -package ro.ieval.unical; - -import java.util.GregorianCalendar; - -import android.app.Activity; -import android.os.Bundle; -import android.view.Window; - -public class AlarmActivity extends Activity { - @Override - public void onCreate(Bundle savedInstanceState) { - super.onCreate(savedInstanceState); - this.requestWindowFeature(Window.FEATURE_NO_TITLE); - setContentView(layoutResID); - - GregorianCalendar cal = (GregorianCalendar) GregorianCalendar.getInstance(); - cal.add(GregorianCalendar.SECOND, 5); - } -} diff --git a/src/ro/ieval/unical/EventListActivity.java b/src/ro/ieval/unical/EventListActivity.java index d864079..27eaef5 100644 --- a/src/ro/ieval/unical/EventListActivity.java +++ b/src/ro/ieval/unical/EventListActivity.java @@ -3,7 +3,6 @@ package ro.ieval.unical; import java.util.Arrays; import java.util.Comparator; import java.util.Date; - import android.app.Activity; import android.content.Intent; import android.os.Bundle; diff --git a/src/ro/ieval/unical/Utils.java b/src/ro/ieval/unical/Utils.java index 703c8dd..73e2737 100644 --- a/src/ro/ieval/unical/Utils.java +++ b/src/ro/ieval/unical/Utils.java @@ -1,7 +1,13 @@ package ro.ieval.unical; +import java.util.GregorianCalendar; import java.util.Locale; +import android.app.Activity; +import android.app.AlarmManager; +import android.app.PendingIntent; +import android.content.Context; +import android.content.Intent; import android.view.View; import android.view.ViewGroup; @@ -20,4 +26,11 @@ final class Utils { public static String formatDate(final int year, final int month, final int day){ return String.format(Locale.ENGLISH, "%4d-%02d-%02d", year, month, day); } + + public static void setAlarm(GregorianCalendar cal,Context context) { + Intent in = new Intent(context,AlarmReceiverActivity.class); + PendingIntent pi = PendingIntent.getActivity(context, 1234, in, PendingIntent.FLAG_CANCEL_CURRENT); + AlarmManager am = (AlarmManager)context.getSystemService(Activity.ALARM_SERVICE); + am.set(AlarmManager.RTC_WAKEUP, cal.getTimeInMillis(), pi); + } }