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


Java Notification.FLAG_FOREGROUND_SERVICE屬性代碼示例

本文整理匯總了Java中android.app.Notification.FLAG_FOREGROUND_SERVICE屬性的典型用法代碼示例。如果您正苦於以下問題:Java Notification.FLAG_FOREGROUND_SERVICE屬性的具體用法?Java Notification.FLAG_FOREGROUND_SERVICE怎麽用?Java Notification.FLAG_FOREGROUND_SERVICE使用的例子?那麽, 這裏精選的屬性代碼示例或許可以為您提供幫助。您也可以進一步了解該屬性所在android.app.Notification的用法示例。


在下文中一共展示了Notification.FLAG_FOREGROUND_SERVICE屬性的7個代碼示例,這些例子默認根據受歡迎程度排序。您可以為喜歡或者感覺有用的代碼點讚,您的評價將有助於係統推薦出更棒的Java代碼示例。

示例1: getForegroundServiceList

public List<String> getForegroundServiceList() {
    List<String> list = new ArrayList<>();

    if (mNotificationService != null) {
        StatusBarNotification[] notifications = mNotificationService.getActiveNotifications();
        for (StatusBarNotification notification : notifications) {
            int mask = Notification.FLAG_FOREGROUND_SERVICE;
            if ((notification.getNotification().flags & mask) != 0) {
                list.add(notification.getPackageName());
            }
        }
    }

    return list;
}
 
開發者ID:mthli,項目名稱:Mount,代碼行數:15,代碼來源:MountApplication.java

示例2: getServiceNotification

/**
 *
 * @return
 */
private Notification getServiceNotification (String text) {
   // Bitmap logo = BitmapFactory.decodeResource(getResources(), R.drawable.logo);

    Notification.Builder builder = new Notification.Builder(this);
    builder.setContentTitle(getString(R.string.service_notification_title))
            .setContentText(text)
            .setSmallIcon(R.drawable.logo)
            .setOngoing(true)
            .setPriority(Notification.PRIORITY_HIGH)
            .setSound(null)
            .setVibrate(null);

    //builder.setSmallIcon(xx);
    builder.setDefaults(Notification.DEFAULT_LIGHTS);

    Notification not = builder.build();
    not.flags = Notification.FLAG_FOREGROUND_SERVICE;

    return not;
}
 
開發者ID:ehanoc,項目名稱:xwallet,代碼行數:24,代碼來源:BlockchainService.java

示例3: getNotification

public static Notification getNotification(Context context, PendingIntent pendingIntent, Track track, boolean isPlaying) {

        Notification notification = new Notification();
        if (track != null) {
            notification.contentView = getNotificationViews(track, context, isPlaying);
        }
        else {
            notification.setLatestEventInfo(context, "", "", pendingIntent);
        }
        notification.flags |= Notification.FLAG_FOREGROUND_SERVICE;
        notification.contentIntent = pendingIntent;
        notification.icon = R.drawable.ic_notification;

        return notification;
    }
 
開發者ID:dmllr,項目名稱:IdealMedia,代碼行數:15,代碼來源:NotificationUtils.java

示例4: show

public void show(){
    build();
    Notification notification = cBuilder.build();
    if(forgroundService){
        notification.flags = Notification.FLAG_FOREGROUND_SERVICE;
    }

  NotifyUtil.notify(id,notification);
}
 
開發者ID:Wilshion,項目名稱:HeadlineNews,代碼行數:9,代碼來源:BaseBuilder.java

示例5: 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

示例6: isForeground

private boolean isForeground(int flags) {
    return (flags & Notification.FLAG_FOREGROUND_SERVICE) != 0;
}
 
開發者ID:rootkiwi,項目名稱:an2linuxclient,代碼行數:3,代碼來源:NotificationService.java

示例7: startForegroundNotification

/**
 * Starts the given notification flagged as a foreground service.
 *
 * @param notification   to be started
 * @param notificationId for the provided notification
 */
private void startForegroundNotification(Notification notification, int notificationId) {
  notification.flags = Notification.FLAG_FOREGROUND_SERVICE;
  startForeground(notificationId, notification);
}
 
開發者ID:mapbox,項目名稱:mapbox-navigation-android,代碼行數:10,代碼來源:NavigationService.java


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