I was trying to pass a variable named choice to another class but I do not know how I should go along doing this because it is inside the onClick. Here is an example of what I am trying to do.
public int choice;
@Override
protected void onCreate(Bundle savedInstanceState) {
    super.onCreate(savedInstanceState);
    setContentView(R.layout.activity_main);
    //intent for first button
    Button button1= (Button) findViewById(R.id.button1);
    button1.setOnClickListener(new View.OnClickListener() {
        public void onClick(View v) {
            choice = 1;
            startActivity(new Intent(MainActivity.this,Celeb1.class));
        }
    });
    //intent for second button
    Button button2= (Button) findViewById(R.id.button2);
    button2.setOnClickListener(new View.OnClickListener() {
        public void onClick(View v) {
            choice = 2;
            startActivity(new Intent(MainActivity.this,Celeb1.class));
        }
    });
}
In a different class I would like to check if choice is equal to 1 or 0 and execute some code.
 
     
    