本文整理匯總了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;
}