所以我在我的活动中创建了此通知
Notification n = new Notification.Builder(getApplicationContext())
.setContentTitle("New mail from " + sender)
.setContentText(subject)
.setSmallIcon(R.drawable.notification)
.build();
我现在如何将其与声音一起显示在状态/通知栏中?
有一些好的Android 开发者网站上的文档 http://developer.android.com/guide/topics/ui/notifiers/notifications.html看看通知管理器 http://developer.android.com/reference/android/app/NotificationManager.html doc's
给你一些代码...:
NotificationManager mNotificationManager =
(NotificationManager) getSystemService(Context.NOTIFICATION_SERVICE);
// mId allows you to update the notification later on.
mNotificationManager.notify(mId, n);
请注意,将您的意图添加到通知中也是一个好主意......
mBuilder.setContentIntent(resultPendingIntent);
要添加声音,您可以使用Notification.Builder.setSound()
method.
本文内容由网友自发贡献,版权归原作者所有,本站不承担相应法律责任。如您发现有涉嫌抄袭侵权的内容,请联系:hwhale#tublm.com(使用前将#替换为@)