安卓:是什么setFlags和addFlags的意图之间的差异意图、差异、setFlags、addFlags

由网友(世俗)分享简介:什么是setFlags和addFlags的意图之间的差异。难道任何一个解释吧。帮助鸭preciated。What is difference between setFlags and addFlags for intent. Could any one explain it please.Help Appreci...

什么是setFlags和addFlags的意图之间的差异。难道任何一个解释吧。 帮助鸭preciated。

What is difference between setFlags and addFlags for intent. Could any one explain it please. Help Appreciated.

推荐答案

在使用 setFlags 要更换旧的标志......当您使用 addFlags 您appening新的标志。记,标志仅仅是一个整数,它是两个功率......二进制,标志是这样的:1,10,100,1000,等...(在此情况下为1,2,4,8)的。那么,是什么 addFlags 不被追加整数你通过使用 | 运营商

When you use setFlags you are replacing the old flags... when you use addFlags you are appening new flags. Remember, a flag is just a integer which is power of two... in binary, flags look like this: 1, 10, 100, 1000, etc... (which in this case are 1, 2, 4, 8). So, what addFlags does is appending the integer you pass using the | operator.

// example... 
// value of flags: 1
intent.setFlags(2|4); 
// now flags have this value: 110
intent.addFlags(8); 
// now flags have this value: 1110
阅读全文

相关推荐

最新文章