本文整理汇总了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;
}
示例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;
}
示例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;
}
示例4: show
public void show(){
build();
Notification notification = cBuilder.build();
if(forgroundService){
notification.flags = Notification.FLAG_FOREGROUND_SERVICE;
}
NotifyUtil.notify(id,notification);
}
示例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;
}
示例6: isForeground
private boolean isForeground(int flags) {
return (flags & Notification.FLAG_FOREGROUND_SERVICE) != 0;
}
示例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);
}