+++ /dev/null
-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);
- }
-}
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;
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);
+ }
}