當前位置: 首頁>>代碼示例>>Java>>正文


Java Notification.PRIORITY_HIGH屬性代碼示例

本文整理匯總了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;
}
 
開發者ID:nordfalk,項目名稱:EsperantoRadio,代碼行數:31,代碼來源:AfspillerIkonOgNotifikation.java


注:本文中的android.app.Notification.PRIORITY_HIGH屬性示例由純淨天空整理自Github/MSDocs等開源代碼及文檔管理平台,相關代碼片段篩選自各路編程大神貢獻的開源項目,源碼版權歸原作者所有,傳播和使用請參考對應項目的License;未經允許,請勿轉載。