我不明白为什么:
if((flags & (Service.START_FLAG_REDELIVERY |Service.START_FLAG_RETRY) != 0)
// 2 flags are present.
,因为:
if((flags & (Service.START_FLAG_REDELIVERY |Service.START_FLAG_RETRY) != 0)
//it means that at least one of the 2 is present.
假设flags = XY:
if((flags & (Service.START_FLAG_REDELIVERY |Service.START_FLAG_RETRY) != 0)
//means that X!=0 or Y!=0 not X!=0 and Y!=0.
答案 0 :(得分:-1)
它是二进制标志,你需要二元运算符(|)来连接它,不是逻辑运算符。
答案 1 :(得分:-1)
public static final int START_FLAG_REDELIVERY = 1; public static final int START_FLAG_RETRY = 2;
0x01 | 0x02 ==> 0x03 ==>二进制00000011 ===> &安培;旗帜