如何显示在状态栏通知? [英] How to show notification in status bar?
本文介绍了如何显示在状态栏通知?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!
问题描述
所以,我在我的活动创造了这个通知
So i have created this notification in my activity
Notification n = new Notification.Builder(getApplicationContext())
.setContentTitle("New mail from " + sender)
.setContentText(subject)
.setSmallIcon(R.drawable.notification)
.build();
与声音一起
如何我现在在状态显示它/通知栏?
How can i now show it in status/notification bar along with the sound?
推荐答案
有一些很好的的文档在Android开发者网站
并有一看 NotificationManager 文档的
在这里,你走了,一些code ...
Here you go, some code...:
NotificationManager mNotificationManager =
(NotificationManager) getSystemService(Context.NOTIFICATION_SERVICE);
// mId allows you to update the notification later on.
mNotificationManager.notify(mId, n);
请注意,这也是一个感伤的想法添加您打算通知...
Note that it is also a goo idea to add your intend to the notification...
mBuilder.setContentIntent(resultPendingIntent);
要添加声音,你可以使用 Notification.Builder.setSound()
方法。
To add sound you can use the Notification.Builder.setSound()
method.
这篇关于如何显示在状态栏通知?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!
查看全文