Draw between Activities

Asked

Viewed 25 times

-2

Good afternoon, I was wondering how do I choose a maximum number in one Activity and the other make a draw with the maximum number being the one chosen in the first Activity

  • Your question is not very clear, try to rephrase it and add more details. Also post the code you already have and what is your specific doubt.

1 answer

1

Your question is not very clear, but what you probably want is to pass data between activities. For that, you will need a Intent.

Assuming you have generated one int and want to pass it between activities:

int seuNumero = 10;

Intent intent = new Intent(SUA_ACTIVITY_ATUAL.class, ACTIVITY_DE_DESTINO.class);
intent.putExtra("seuNumero", seuNumero);
startActivity(intent);

In the Activity destination, you need the following code to recover your number:

int numero = getIntent().getIntExtra("seuNumero");

Stick to the method getIntExtra(). It is used to recover a value of type int. If you’re dealing with double, will use getDoubleExtra() etc..

Browser other questions tagged

You are not signed in. Login or sign up in order to post.