我一直在通过 Anna Xu 的youtube 教程制作闹钟
她最终将她的代码保留在 If 语句中,它似乎可以点击并调出她的应用程序。我已经根据在 Pixel XL 上搜索 Oreo 的修复程序进行了修改。这是我到目前为止所拥有的:
// notification parameters
int notifyID = 1;
String CHANNEL_ID = "my channel_01";
CharSequence name = "Hello";
int importance = NotificationManager.IMPORTANCE_HIGH;
NotificationChannel mChannel = new NotificationChannel(CHANNEL_ID, name, importance);
// set up the notification service
NotificationManager notify_manager = (NotificationManager)
getSystemService(Context.NOTIFICATION_SERVICE);
notify_manager.createNotificationChannel(mChannel);
Notification notification_popup = new Notification.Builder(this)
.setSmallIcon(R.drawable.ic_launcher_foreground)
.setContentTitle("An alarm is going off!")
.setContentText("Click me!")
.setChannelId(CHANNEL_ID).build();
// set up notification start command
notify_manager.notify(0, notification_popup);
这会在警报响起时弹出通知,但点击并不会弹出应用程序,实际上我认为您根本无法点击它,您只能将其滑开。我只想能够单击通知将应用程序带到前台。我是 Java 和 Android Studio 的超级新手,现在奥利奥系统闹钟不可信,这一切都是必要的提示。任何帮助都会很棒。