Stopping Alarm Android Application

亡梦爱人 提交于 2019-12-02 11:35:09

Hi you can use the following command passing your pending intent:

am.cancel(yourPendingIntent);

I have written a good tutorial on AlarmManager some months ago that you can find at this link

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);

        .....
标签
易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!