繁体   English   中英

每天Android重复通知

[英]Android Repeat notification every day

我想每天重复我的通知,我已经执行了这段代码,没有错误,但是它并没有每天重复我的通知。问题出在哪里?

NotificationCompat.Builder mBuilder = (android.support.v7.app.NotificationCompat.Builder) new NotificationCompat.Builder(this)
        .setSmallIcon(R.drawable.tick)
        .setWhen(Calendar.DAY_OF_WEEK)
        .setContentTitle("My notification")
        .setContentText("Hello World!");


Intent notificationIntent = new Intent(this, MainActivity.class);

PendingIntent contentIntent = PendingIntent.getActivity(this, 0, notificationIntent,
        PendingIntent.FLAG_UPDATE_CURRENT);

mBuilder.setContentIntent(contentIntent);


NotificationManager manager = (NotificationManager) getSystemService(Context.NOTIFICATION_SERVICE);
manager.notify(0, mBuilder.build());

为此,您应该使用AlarmManager 以下链接将为您提供帮助。

Android基础知识:安排重复任务

使用AlarmManager在Android中重复警报示例

系统杀死了进程。 您可以采取措施使其保持生命

暂无
暂无

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM