There is an application with 2 active. In the first - one button called Menu number one. You press, you get into the second activation, and in the onCreate method, a onCreate is executed.

 public class Main2Activity extends Activity implements View.OnClickListener{ public ArrayList<Integer> Arrayl; @Override protected void onCreate(Bundle savedInstanceState) { super.onCreate(savedInstanceState); setContentView(R.layout.activity_main2); Button b2 = (Button)findViewById(R.id.button2); b2.setOnClickListener(this); Arrayl = new ArrayList<>(); for (int a = 1; a < 8; a++) { Arrayl.add(a); } Collections.shuffle(Arrayl);// перемешиваем Log.d("","ТУТ:" +Arrayl.toString()); } @Override public void onClick(View v) { Intent gotoanotheractivity = new Intent(Main2Activity.this, MainActivity.class); startActivity(gotoanotheractivity); } } 

Further, you press the Main menu button and you get back to the first activation, where there is the Menu number one button.

So, the task : when I go into the second activation the second time, the following cycle should be executed:

 Arrayl = new ArrayList<>(); for (int a = 8; a < 25; a++) { Arrayl.add(a); } Collections.shuffle(Arrayl);// перемешиваем Log.d("","ТУТ:" +Arrayl.toString()); 

Tell me, even an idea how this can be done?

    1 answer 1

    In the first activation, you can create a flag that will indicate whether the second activation is launched for the first time or not.

    When the second activation is launched, this flag can be passed in the intent , and in the onCreate(...) method of the second activation, this flag can be retrieved from the intent and, depending on this flag, perform certain actions.