Android的 - 通知经理,有一个通知,没有意图 [英] Android - notification manager, having a notification without an intent
本文介绍了Android的 - 通知经理,有一个通知,没有意图的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!
问题描述
我希望能够触发通知,提醒有关已完成了定时器的用户,但是我不希望有一个意图,当您单击该通知。
I would like to be able to fire a notification to alert the users about a timer that has finished, however i do not wish to have an intent when you click the notification.
我试过传递空的意图
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);
推荐答案
您可以通过参数
You may pass the parameter
而不是
null
在
notification.setLatestEventInfo(背景下,contentTitle,contentText,NULL);
这篇关于Android的 - 通知经理,有一个通知,没有意图的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!
查看全文