以下代码取自Message中:
本文主要讲优先级
重点代码:.setPriority(Notification.PRIORITY_HIGH)
public static void postNewMessageSecondaryUserNotification() {
final Context context = Factory.get().getApplicationContext();
final Resources resources = context.getResources();
final PendingIntent pendingIntent = UIIntents.get()
.getPendingIntentForSecondaryUserNewMessageNotification(context);
final NotificationCompat.Builder builder = new NotificationCompat.Builder(context);
builder.setContentTitle(resources.getString(R.string.secondary_user_new_message_title))
.setTicker(resources.getString(R.string.secondary_user_new_message_ticker))
.setSmallIcon(R.drawable.ic_sms_light)
// Returning PRIORITY_HIGH causes L to put up a HUD notification. Without it, the ticker
// isn't displayed.弹出式状态栏横幅通知setpriority()可用来设置进程、进程组和用户的进程 //执行优先权。
.setPriority(Notification.PRIORITY_HIGH)
.setContentIntent(pendingIntent);
final NotificationCompat.BigTextStyle bigTextStyle =
new NotificationCompat.BigTextStyle(builder);
bigTextStyle.bigText(resources.getString(R.string.secondary_user_new_message_title));
final Notification notification = bigTextStyle.build();
final NotificationManagerCompat notificationManager =
NotificationManagerCompat.from(Factory.get().getApplicationContext());
int defaults = Notification.DEFAULT_LIGHTS|Notification.DEFAULT_SOUND;
if (BugleNotifications.shouldVibrate(new SecondaryUserNotificationState())) {
defaults |= Notification.DEFAULT_VIBRATE;
}
notification.defaults = defaults;
notificationManager.notify(getNotificationTag(),
PendingIntentConstants.SMS_SECONDARY_USER_NOTIFICATION_ID, notification);
}