What does the |= operator do in Java?

前端 未结 6 740
暗喜
暗喜 2020-12-06 10:15

While reading the Android guide to Notifications, I stumbled across this:

Adding vibration

You can alert the user with th

6条回答
  •  天涯浪人
    2020-12-06 10:45

    In this case, notification.defaults is a bit array. By using |=, you're adding Notification.DEFAULT_VIBRATE to the set of default options. Inside Notification, it is likely that the presence of this particular value will be checked for like so:

    notification.defaults & Notification.DEFAULT_VIBRATE != 0 // Present
    

提交回复
热议问题