Hello, I am new in android. I am using AlarmMagener in my application. i am setting Alarm to some date. now i am giving direct date. when the system date is not equal to hardcoded date alarm in not invoking. But when i change system date to given date still is not invoking.
Please help me where i am going wrong and how i proceed. this is my Activity package com.exercise.AndroidAlarmService; import java.util.Calendar; import android.app.Activity; import android.app.AlarmManager; import android.app.PendingIntent; import android.content.Intent; import android.os.Bundle; import android.os.SystemClock; import android.view.View; import android.widget.Button; import android.widget.Toast; public class AndroidAlarmService extends Activity { private PendingIntent pendingIntent; String full=""; @Override public void onCreate(Bundle savedInstanceState) { super.onCreate(savedInstanceState); Intent myIntent = new Intent(AndroidAlarmService.this, MyAlarmService.class); pendingIntent = PendingIntent.getService(AndroidAlarmService.this, 0, myIntent, 0); setContentView(R.layout.main); Button buttonStart = (Button)findViewById(R.id.startalarm); Button buttonCancel = (Button)findViewById(R.id.cancelalarm); buttonStart.setOnClickListener(new Button.OnClickListener() { @Override public void onClick(View arg0) { AlarmManager alarmManager = (AlarmManager)getSystemService(ALARM_SERVICE); Calendar calendar = Calendar.getInstance(); int month=calendar.get(Calendar.MONTH); int month1=month+1; int date=calendar.get(Calendar.DATE); int year=calendar.get(Calendar.YEAR); full=month1+"/"+date+"/"+year; int h=calendar.get(Calendar.HOUR_OF_DAY); int m=calendar.get(Calendar.MINUTE); calendar.set(Calendar.HOUR_OF_DAY, h); calendar.set(Calendar.MINUTE,55); calendar.set(Calendar.SECOND, 0); calendar.set(Calendar.MILLISECOND, 0); //calendar.setTimeInMillis(System.currentTimeMillis()); //calendar.add(Calendar.SECOND, 10); if(full.equals("7/31/2011")) { alarmManager.setRepeating(AlarmManager.RTC_WAKEUP, calendar.getTimeInMillis(), SystemClock.elapsedRealtime(), pendingIntent); Toast.makeText(AndroidAlarmService.this, "Start Alarm " +" "+full+"- "+h+":"+m , Toast.LENGTH_LONG).show(); //Alerts.ShowEmpAddedAlert(this); } } }); buttonCancel.setOnClickListener(new Button.OnClickListener() { @Override public void onClick(View arg0) { // TODO Auto-generated method stub AlarmManager alarmManager = (AlarmManager)getSystemService(ALARM_SERVICE); alarmManager.cancel(pendingIntent); // Tell the user about what we did. Toast.makeText(AndroidAlarmService.this, "Cancel!", Toast.LENGTH_LONG).show(); } }); } } this is my Service package com.exercise.AndroidAlarmService; import android.app.Service; import android.content.Intent; import android.os.IBinder; import android.widget.Toast; public class MyAlarmService extends Service { @Override public void onCreate() { // TODO Auto-generated method stub Toast.makeText(this, "MyAlarmService.onCreate()", Toast.LENGTH_LONG).show(); } @Override public IBinder onBind(Intent intent) { // TODO Auto-generated method stub Toast.makeText(this, "MyAlarmService.onBind()", Toast.LENGTH_LONG).show(); return null; } @Override public void onDestroy() { // TODO Auto-generated method stub super.onDestroy(); Toast.makeText(this, "MyAlarmService.onDestroy()", Toast.LENGTH_LONG).show(); } @Override public void onStart(Intent intent, int startId) { // TODO Auto-generated method stub super.onStart(intent, startId); Toast.makeText(this, "MyAlarmService.onStart()", Toast.LENGTH_LONG).show(); } @Override public boolean onUnbind(Intent intent) { // TODO Auto-generated method stub Toast.makeText(this, "MyAlarmService.onUnbind()", Toast.LENGTH_LONG).show(); return super.onUnbind(intent); } } -- You received this message because you are subscribed to the Google Groups "Android Developers" group. To post to this group, send email to android-developers@googlegroups.com To unsubscribe from this group, send email to android-developers+unsubscr...@googlegroups.com For more options, visit this group at http://groups.google.com/group/android-developers?hl=en