tangguo

Android-通知管理器,具有无意图的通知

android

我希望能够发出通知,以提醒用户有关计时器已结束的信息,但是,当您单击通知时,我不希望有任何意图。

我已经尝试将null传递给意图

String ns = Context.NOTIFICATION_SERVICE;
NotificationManager mNotificationManager = (NotificationManager) context.getSystemService(ns);

int icon = R.drawable.icon;
CharSequence tickerText = "Hello";
long when = System.currentTimeMillis();

Notification notification = new Notification(icon, tickerText, when);

CharSequence contentTitle = "My notification";
CharSequence contentText = "Hello World!";

notification.setLatestEventInfo(context, contentTitle, contentText, null);
mNotificationManager.notify(HELLO_ID, notification);

阅读 532

收藏
2020-10-22

共1个答案

小编典典

您可以传递参数

PendingIntent.getActivity(getApplicationContext(), 0, new Intent(), 0)

代替

null

notification.setLatestEventInfo(context, contentTitle, contentText, null);
2020-10-22