这在这里一个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)和赋值。 –