我希望能够发出通知,以提醒用户有关计时器已结束的信息,但是,当您单击通知时,我不希望有任何意图。
我已经尝试将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);