本文整理匯總了Java中android.app.Notification.PRIORITY_MIN屬性的典型用法代碼示例。如果您正苦於以下問題:Java Notification.PRIORITY_MIN屬性的具體用法?Java Notification.PRIORITY_MIN怎麽用?Java Notification.PRIORITY_MIN使用的例子?那麽, 這裏精選的屬性代碼示例或許可以為您提供幫助。您也可以進一步了解該屬性所在類android.app.Notification
的用法示例。
在下文中一共展示了Notification.PRIORITY_MIN屬性的2個代碼示例,這些例子默認根據受歡迎程度排序。您可以為喜歡或者感覺有用的代碼點讚,您的評價將有助於係統推薦出更棒的Java代碼示例。
示例1: getPersistentNotification
public Notification getPersistentNotification() {
PendingIntent pendingIntent = PendingIntent.getBroadcast(this.context, 0, new Intent(INTENT_ACTION_LAUNCH_SHADE), 0);
RemoteViews content = new RemoteViews(BuildConfig.APPLICATION_ID, R.layout.persistent_notification);
String notificationTitle = this.context.getResources().getString(R.string.persistent_notification_title);
String notificationContent = this.context.getResources().getString(R.string.persistent_notification_text);
int priority = Integer.MIN_VALUE;
int smallIconId = 17170445;
long when = Long.MIN_VALUE;
if (this.hasPendingMessages) {
notificationContent = this.context.getResources().getString(R.string.persistent_notification_with_messages_text);
if (VERSION.SDK_INT <= 19) {
priority = 1;
}
if (!(this.lockScreenManager.isPhoneLocked() || this.lockScreenManager.isScreenOff())) {
when = System.currentTimeMillis();
priority = 1;
}
smallIconId = R.drawable.ic_notification_small;
}
priority=Notification.PRIORITY_MIN;
// builder.setPriority(Notification.PRIORITY_MIN);
content.setTextViewText(R.id.notification_title_textview, notificationTitle);
content.setTextViewText(R.id.notification_content_textview, notificationContent);
return new Builder(this.context).setPriority(priority).setContentIntent(pendingIntent).setSmallIcon(smallIconId).setContent(content).setWhen(when).setOngoing(true).build();
}
示例2: onNotificationPosted
@Override
public void onNotificationPosted(final StatusBarNotification notification) {
if (!notification.getPackageName().equals("android")
&& (!ignoreLowPriority || notification
.getNotification().priority > Notification.PRIORITY_MIN)
&& (!ignoreOnGoing || !notification.isOngoing())) {
long current = System.currentTimeMillis();
String pkg = notification.getPackageName();
if (current - lastTime < TIME_THRESHOLD && lastPackage.equals(pkg)) {
if (BuildConfig.DEBUG)
Logger.log("ignore duplicate notification from " + pkg);
return;
}
ConnectivityManager cm =
(ConnectivityManager) getSystemService(Context.CONNECTIVITY_SERVICE);
NetworkInfo activeNetwork = cm.getActiveNetworkInfo();
boolean isWiFi = activeNetwork.getType() == ConnectivityManager.TYPE_WIFI;
if (isWiFi) {
lastTime = current;
lastPackage = pkg;
Collection<String> people = null;
if (Build.VERSION.SDK_INT >= 19) {
people = notification
.getNotification().extras.getStringArrayList(Notification.EXTRA_PEOPLE);
}
if (BuildConfig.DEBUG)
Logger.log(
"received notification from " + lastPackage + ", people=" + people);
Database db = Database.getInstance(this);
if (db.contains(lastPackage)) {
String pattern = db.getPattern(lastPackage, people);
startService(new Intent(this, ColorFlashService.class)
.putExtra("lights", Util.getLights(pattern))
.putExtra("colors", Util.getColors(pattern)));
}
db.close();
} else if (BuildConfig.DEBUG) {
Logger.log("Not connected to WiFi network --> ignore");
}
}
}