In the context of the accepted answer referenced in your comments, the poster is simply using these values as id's for dynamically added menu items so that clicks can be registered in inOptionsItemSelected()
.
For example, say you wanted to add a new button to your menu
dynamically that turned the screen blue, you might create a constant value called MENU_TURN_SCREEN_BLUE
. This would store an arbitrary number which you can later use as an id. For example (keeping in mind Menu.FIRST = 1
:
private static final int MENU_TURN_SCREEN_BLUE = Menu.FIRST + 60;
or
private static final int MENU_TURN_SCREEN_BLUE = 69084;
Are both valid. Now, when you add a new item to a menu with the add()
method, you can use this value:
menu.add(0, TURN_SCREEN_BLUE, 0, "Press To Turn Screen Blue");
You could of course just write the number in directly, but constant are helpful (amongst other reasons) for avoiding bugs in your code that arise from accidentally typing in the wrong number.
Keep in mind though that there are other ways to generate unique id's - see this question for details.