当前位置: 首页>>代码示例>>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;未经允许,请勿转载。