我有一个Android应用程序。我必须在上午9点15分,上午11点,下午2点和下午4点添加4个任务来运行相同的工作。有没有办法经营同样的工作4次?我只能通过警报管理员完成一项任务。
如何配置多个警报?
答案 0 :(得分:0)
创建4个PendingIntents,它们调用相同的服务/活动/广播,但为每个服务/活动/广播使用不同的请求代码。
Intent serviceToStart = new Intent(context, YourService.class);
PendingIntent execute915am = PendingIntent.getService(context, 1, serviceToStart, 0);
PendingIntent execute11am = PendingIntent.getService(context, 2, serviceToStart, 0);
PendingIntent execute2pm = PendingIntent.getService(context, 3, serviceToStart, 0);
PendingIntent execute4pm = PendingIntent.getService(context, 4, serviceToStart, 0);