這在這裏一個Android通知用於:在java中是什麼意思?
http://www.vogella.com/articles/AndroidNotifications/article.html#notificationmanager_configure
// Hide the notification after its selected
noti.flags |= Notification.FLAG_AUTO_CANCEL;
這在這裏一個Android通知用於:在java中是什麼意思?
http://www.vogella.com/articles/AndroidNotifications/article.html#notificationmanager_configure
// Hide the notification after its selected
noti.flags |= Notification.FLAG_AUTO_CANCEL;
按位或分配。
int a = 6, b = 5;
a = a | b;
// is equivalent to
a |= b;
在像Android這樣的系統中,將許多不同的布爾屬性壓縮爲一個整數值通常是有意義的。數值可以與|
相結合,並使用&
進行測試。
// invented constants for example
public static final int HAS_BORDER = 1; // in binary: 0b00000001
public static final int HAS_FRAME = 2; // 0b00000010
public static final int HAS_TITLE = 4; // 0b00000100
public void exampleMethod() {
int flags = 0; // flags = 0b00000000
flags |= HAS_BORDER; // 0b00000001
flags |= HAS_TITLE; // 0b00000101
if ((flags & HAS_BORDER) != 0) {
// do x
}
if ((flags & HAS_TITLE) != 0) {
// do y
}
}
'a = a | b'相當於'a = a | B'? –
@LuiggiMendoza謝謝。這很愚蠢。 –
同:
noti.flags = noti.flags | Notification.FLAG_AUTO_CANCEL;
所有位OR
「編在一起。這通常是加上一個標誌到一組現有標誌的好方法,因爲Notification.FLAG_AUTO_CANCEL
可能只是設置了一個位,所以該位將是開啓在noti.flags
。
[邏輯OR](http://www.erpgreat.com/java/java-boolean-logical-operators.htm)和賦值。 –