我想每天重复我的通知,我已经做了这个代码,没有错误,但它不会每天重复我的通知......问题出在哪里?
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
。以下链接将为您提供帮助。
系统杀死了这个过程。你可以采取措施让它保持活力