Warning: file_get_contents(/data/phpspider/zhask/data//catemap/2/facebook/9.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
如何使用Android服务标志?_Android - Fatal编程技术网

如何使用Android服务标志?

如何使用Android服务标志?,android,Android,我不明白为什么: 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 pre

我不明白为什么:

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.

它是二进制标志,需要二进制运算符(|)来连接它,而不是逻辑运算符

public static final int START\u FLAG\u REDELIVERY=1; 公共静态最终整数开始标志重试=2

0x01 | 0x02==>0x03==>Binary 00000011====>flag&