Stopping Alarm Android Application

后端 未结 2 542
别那么骄傲
别那么骄傲 2021-01-28 18:40

Can anyone tell me how can I stop this alarm?

I\'m trying to stop it by using a handler but it didn\'t stop it continues to repeat?

Here\'s my code:

//==

2条回答
  •  日久生厌
    2021-01-28 18:58

    make alarm manager global so that the various functions are referencing the same object

     Button bStart, bStop ;
         long mCurrentTime;
         Calendar calendar;
         TextView tv;
         AlarmManager am
        @Override
        public void onCreate(Bundle savedInstanceState) {
            super.onCreate(savedInstanceState);
            setContentView(R.layout.main);
    
           ...
           ...
    
            Intent intent = new Intent(AlarmNewActivity.this, RepeatingAlarm.class);
            PendingIntent sender = PendingIntent.getBroadcast(AlarmNewActivity.this, 0, intent, 0);
            am = (AlarmManager)getSystemService(ALARM_SERVICE);
    
            .....
    

提交回复
热议问题