通知标志的值为-3
我正在编写自定义上传通知,与 Picasa 照片上传器的通知非常相似 http://code.google .com/p/picasaphotouploader/source/browse/trunk/src/com/android/picasaphotouploader/UploadNotification.java
在创建时,我设置了FLAG_ONGOING_EVENT
并且它有效。上传完成后,我有这两行:
flags =~Notification.FLAG_ONGOING_EVENT; 标志+=通知.FLAG_AUTO_CANCEL;
但是,我的通知不可取消,并且 flags
的值为 -3。 你知道为什么我不能再更改标志了吗?
I'm writing a custom upload notification, very similar to that from the Picasa Photo Uploader
http://code.google.com/p/picasaphotouploader/source/browse/trunk/src/com/android/picasaphotouploader/UploadNotification.java
At creation, I set the FLAG_ONGOING_EVENT
and it works. After the upload is done, i have these two lines:
flags =~ Notification.FLAG_ONGOING_EVENT;
flags += Notification.FLAG_AUTO_CANCEL;
However, my notification is not cancelable, and flags
has a value of -3.
Do you have any idea why I can't change the flags anymore?
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(1)
答案很晚,但以防万一其他人遇到这个问题。我相信您应该在这里使用按位运算而不是算术运算。
在这种情况下使用:
这可能看起来很奇怪,因为如果您不知道按位运算,您的直觉会告诉您“不是正在进行的或自动取消”,但它实际上意味着禁用正在进行的位并启用自动取消位。
我建议阅读按位运算符和位掩码。
A late answer but just in case someone else runs into this issue. I believe you should be using bitwise operations instead of arithmatic operations here.
In this case use:
This may look weird because, if you don't know bitwise operations, your instincts tell you "not ongoing or auto cancel" but it really means to disable the ongoing bit and to enable the auto cancel bit.
I suggest reading up on bitwise operators and bit masks.