本文整理汇总了Java中android.app.Notification.PRIORITY_HIGH属性的典型用法代码示例。如果您正苦于以下问题:Java Notification.PRIORITY_HIGH属性的具体用法?Java Notification.PRIORITY_HIGH怎么用?Java Notification.PRIORITY_HIGH使用的例子?那么恭喜您, 这里精选的属性代码示例或许可以为您提供帮助。您也可以进一步了解该属性所在类android.app.Notification
的用法示例。
在下文中一共展示了Notification.PRIORITY_HIGH属性的1个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。
示例1: lavNotification
@SuppressLint("NewApi")
public static Notification lavNotification(Context ctx) {
String kanalNavn = App.afspiller.getLydkilde().getKanal().navn;
NotificationCompat.Builder b = new NotificationCompat.Builder(ctx)
.setSmallIcon(R.drawable.dr_notifikation)
.setContentTitle(ctx.getString(R.string.appnavn))
.setContentText(kanalNavn)
.setOngoing(true)
.setAutoCancel(false)
.setVisibility(NotificationCompat.VISIBILITY_PUBLIC)
.setPriority(1001) // holder den øverst
.setContentIntent(PendingIntent.getActivity(ctx, 0, new Intent(ctx, Hovedaktivitet.class), 0));
// PendingIntent er til at pege på aktiviteten der skal startes hvis
// brugeren vælger notifikationen
b.setContent(AfspillerIkonOgNotifikation.lavRemoteViews(AfspillerIkonOgNotifikation.TYPE_notifikation_lille));
Notification notification = b.build();
if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.JELLY_BEAN) {
// A notification's big view appears only when the notification is expanded,
// which happens when the notification is at the top of the notification drawer,
// or when the user expands the notification with a gesture.
// Expanded notifications are available starting with Android 4.1.
notification.bigContentView = AfspillerIkonOgNotifikation.lavRemoteViews(AfspillerIkonOgNotifikation.TYPE_notifikation_stor);
}
notification.flags |= (Notification.FLAG_NO_CLEAR | Notification.FLAG_ONGOING_EVENT | Notification.PRIORITY_HIGH | Notification.FLAG_FOREGROUND_SERVICE);
return notification;
}