是什么并不意味着这两个运营商的QUOT; | ="和" |" [英] what does mean these two operator "|=" and "|"

查看:178
本文介绍了是什么并不意味着这两个运营商的QUOT; | ="和" |"的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我发现在应用程序源$ C ​​$ C这一行,但我不能弄清楚按位或包容性的运算符 | 的意思。这两个标志之间的

<$p$p><$c$c>notificationIntent.setFlags(Intent.FLAG_ACTIVITY_CLEAR_TOP|Intent.FLAG_ACTIVITY_SINGLE_TOP);

我也没明白这个运营商的意义 |在以下行=

  notification.flags | = Notification.FLAG_AUTO_CANCEL;

有人可以帮助我PLZ。


解决方案

我开始我的答案,而没有其他人回答了,所以我决定无论如何要完成它......

管道和符号 |和与放大器; 分别执行操作

您会看惯 || &放大器;&安培; ,它执行布尔逻辑,并使用一个单一的的|或放大器; 是位运算

如果你看看旗文档上,为clear_top标志为0x04000000,而single_top是0x20000000。

您正在执行的操作因此:
0x04000000 OR 0x20000000 = 0x24000000处

其中设置所需的位中的意图同时使用所需的标志

A | = B 操作符是 A = A重载相当于| b ,类似于 + = 的用法 - ++ ,你应该用在其他地方看到

I have found this line in an application source code but i cant figure out the meaning of the bitwise or inclusive operator "|" between the two flags.

notificationIntent.setFlags(Intent.FLAG_ACTIVITY_CLEAR_TOP|Intent.FLAG_ACTIVITY_SINGLE_TOP);

I did not also understand the meaning of this operator |= in the following line:

notification.flags |= Notification.FLAG_AUTO_CANCEL;

Someone could help me plz.

解决方案

I'd started my answer while no-one else had answered, so I decided to finish it anyway...

The pipe and ampersand | and & perform the OR and AND operations respectively.

You'll be used to seeing || and &&, which perform the boolean logic OR and AND, and the use of a single | or & is a bitwise operation.

If you look on the flag documentation, the flag for clear_top is 0x04000000, and single_top is 0x20000000.

The operation which you are performing is therefore: 0x04000000 OR 0x20000000 = 0x24000000

Which sets the required bits in the intent to use both of the desired flags.

The a |= b operator is the overloaded equivalent of a = a | b, similar to the usage of +=, -- or ++, which you should be used to seeing elsewhere

这篇关于是什么并不意味着这两个运营商的QUOT; | =&QUOT;和&QUOT; |&QUOT;的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
相关文章
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆