Android AlarmManger+service设置通知栏定时推送,清理后失效 5
大致流程是通过AlarmManager设置定时器,AlarmManageram=(AlarmManager)getSystemService(ALARM_SERVICE)...
大致流程是通过AlarmManager设置定时器,
AlarmManager am = (AlarmManager) getSystemService(ALARM_SERVICE);
Intent it = new Intent(AlarmManagerActivity.this,NotificationService.Class);
时间到了启动NotificationService来推送消息,会被系统清理掉,目前不知道被清理的是闹钟还是Service
AlarmManager am = (AlarmManager) getSystemService(ALARM_SERVICE);
Intent it = new Intent(AlarmManagerActivity.this, NotificationService.class);
PendingIntent pi = PendingIntent.getService(AlarmManagerActivity.this, 2, it, PendingIntent.FLAG_CANCEL_CURRENT);
Calendar calendar = Calendar.getInstance();
am.set(AlarmManager.RTC_WAKEUP, calendar.getTimeInMillis() + 5 * 1000, pi);//5S后 展开
AlarmManager am = (AlarmManager) getSystemService(ALARM_SERVICE);
Intent it = new Intent(AlarmManagerActivity.this,NotificationService.Class);
时间到了启动NotificationService来推送消息,会被系统清理掉,目前不知道被清理的是闹钟还是Service
AlarmManager am = (AlarmManager) getSystemService(ALARM_SERVICE);
Intent it = new Intent(AlarmManagerActivity.this, NotificationService.class);
PendingIntent pi = PendingIntent.getService(AlarmManagerActivity.this, 2, it, PendingIntent.FLAG_CANCEL_CURRENT);
Calendar calendar = Calendar.getInstance();
am.set(AlarmManager.RTC_WAKEUP, calendar.getTimeInMillis() + 5 * 1000, pi);//5S后 展开
1个回答
推荐律师服务:
若未解决您的问题,请您详细描述您的问题,通过百度律临进行免费专业咨询