android - 每日重复通知,已弃用 N̶o̶t̶i̶f̶i̶c̶a̶t̶i̶o̶n̶C̶o̶m̶p̶a̶t̶.̶B̶u̶i̶l̶d̶e̶r̶
问题描述
我正在搜索用于创建通知的最新代码,因为我拥有的代码不起作用并且它说该代码已被弃用。
我的代码实际上类似于这个问题的答案,除了我的看起来像这样......
在我的清单上它变成红色,我知道为什么;
但是我也有这个代码(它可以工作),但我想不出如何让它在指定的时间每天重复;
Intent i = new Intent(this,MainActivity.class);
PendingIntent pendingIntent = PendingIntent.getActivity(this, (int) System.currentTimeMillis(), i, 0);
Bitmap bitmapI = BitmapFactory.decodeResource(resources, R.mipmap.ic_launcher_round);
Notification notification = new Notification.Builder(this)
.setContentTitle("Sample title")
.setContentText("Sample content")
.setSmallIcon(R.mipmap.ic_launcher_round)
.setLargeIcon(bitmapI)
.setContentIntent(pendingIntent)
.build();
NotificationManager notificationManager = (NotificationManager) getSystemService(NOTIFICATION_SERVICE);
notification.flags |= Notification.FLAG_AUTO_CANCEL;
notificationManager.notify(0, notification);`
如果你们想看看我的实际代码,就说,我会编辑我的问题。
解决方案
推荐阅读
- php - 如何在不在线公开的情况下将文件存储在 Wordpress 插件中?
- javascript - 如何将默认值设置为来自前缀或输入字段的状态
- mysql - 在 MySQL 工作台的 EER 图中,我在哪里设置外键约束名称?
- python - 给定 3d 张量时,argmax 如何工作 - tensorflow
- java - 有没有办法阻止在另一个 Android 应用程序中显示密码功能?
- javascript - 如果使用 jquery 在密码框中键入了某些内容,则显示和隐藏确认密码框
- r - 减小上标字体大小ggplot2 R
- django - 在网页上显示 Django 外键
- shiro - 我们可以使用 Apache Shiro 与 Angular 8
- dynamic-programming - 我无法理解 o(sum) 空间复杂度中硬币兑换问题的逻辑