Alex Rivera | Logout

What does the |= operator do in Java?

Asked 2010-02-24T10:50:56.197
20

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

Adding vibration

You can alert the user with the the default vibration pattern or with a vibration pattern defined by your application.

To use the default pattern, add "DEFAULT_VIBRATE" to the defaults field:

notification.defaults |= Notification.DEFAULT_VIBRATE;

What this does is clear: it adds the DEFAULT_VIBRATE flag to the default flags of the notification object. But what does the |= operator do in Java? It looks like an "OR", but how does it work?

Can you provide an example using numbers?

Thanks

Edit
Report

1 Answer

1

This is the bit wise OR operator. If notifications.default is 0b00000001 in binary form and Notification.DEFAULT_VIBRATE is 0b11000000, then the result will be 0b11000001.

answered 2010-02-24T10:55:07.223

Your Answer