我希望能够触发通知以提醒用户计时器已完成,但是我不希望在您单击通知时有 Intent 。
我已经尝试为 Intent 传递 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);
最佳答案
你可以传递参数
PendingIntent.getActivity(getApplicationContext(), 0, new Intent(), 0)
而不是
null
开
notification.setLatestEventInfo(context, contentTitle, contentText, null);
关于Android - 通知管理器,有一个没有 Intent 的通知,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/7040742/