我正在写一些类似用户的提醒.用户将为其事件设置提醒,当时间到来时,将设置重复警报以触发状态栏通知.但是在我选择通知或清除通知后,警报似乎不停.我不知道在哪里取消这个重复闹钟.以下是一些代码:在我的主要活动中设置重复警报
alarmTime = Calendar.getInstance();
Intent intent = new Intent(this, AlarmReceive.class);
PendingIntent sender = PendingIntent.getBroadcast(this, 0, intent, 0);
AlarmManager alarmManager = (AlarmManager) getSystemService(ALARM_SERVICE);
alarmTime.add(Calendar.MINUTE,offset_time);
//Schedule the alarm
alarmManager.setRepeating(AlarmManager.RTC_WAKEUP, alarmTime.getTimeInMillis(), 30 * 1000, sender);
Run Code Online (Sandbox Code Playgroud)
在我的OnReceive方法中,我只是在状态栏中显示通知并将标志设置为 FLAG_AUTO_CANCEL
manager = (NotificationManager) context.getSystemService(context.NOTIFICATION_SERVICE);
// Set the icon, scrolling text and timestamp
Notification notification = new Notification(R.drawable.medical, text, System.currentTimeMillis());
PendingIntent contentIntent = PendingIntent.getActivity(context, 0, i, 0);
notification.flags = Notification.FLAG_AUTO_CANCEL;
manager.notify(R.string.service_text, notification);
Run Code Online (Sandbox Code Playgroud)
当用户选择通知或清除通知时,如何停止警报?
如果我使用AlarmManager来安排警报(应该发送的PendintIntent),我如何在以后识别该警报以取消它?我可以取消我的应用安排的所有闹钟吗?
我正在开发一个用作应用程序锁定器的应用程序,这个应用程序可以通过询问用户打开这些应用程序的密码来保护其他已安装的应用程序,我的应用程序在这里
问题是可以通过强制关闭android任务管理器来轻松跳过应用程序,我该如何克服这个问题呢?
另外,检查新应用程序打开的最佳方法是什么,制作一项服务,每隔一秒检查一次应用程序的任务,或者每隔一秒用警报管理器发出警报进行检查.
我正在开发一个应用程序来监控每分钟后的网络.我正在使用BroadcastReceiver.
我想在每分钟后执行BroadcastReceiver.
我该怎么做?我可以在BroadcastReceiver中使用Thread.sleep()吗?
可以继续在Android中运行BroadcastReceiver吗?