title: How do I pass a shuffled arraylist of classes from activity to activity without the list being recreated every time?
body: <p>I've been trying many different methods to pass an arraylist of activity classes in android for an app game . The arraylist starts in MainActivity then through an onClick Listener an element of the arraylist gets called after it has been shuffled. The problem is when this arraylist is called again in a later activity the arraylist has been shuffled again. I don't want the list to be shuffled again unless the user returns to MainActivity. I'm using Collections shuffle to randomize the arraylist. I only want shuffled to be called once through the MainActivity onCreate, then I want to keep that same list. Only if the user returns to MainActivity do I want shuffle to be called again.</p>
  
  <pre><code> public MainActivity extends Activity {
  
     List&lt;Class&lt;?&gt;&gt; listActivities = new ArrayList&lt;Class&lt;?&gt;&gt;();
  
     onCreate {
       arrayList();
     }     
  
    public void arraryList() {
  
       listActivities.add(Activity1.class);
       listActivities.add(Activity2.class);       
       listActivities.add(Activity3.class);
  
       Collections.shuffle(listActivites)
  
    }
  
    //OnClicklistener Button
    OnClick (View v){
  
        // just an example
        if (v) {
  
          Intent intent = new (this, listActivities.get(0))
          startActivity(intent);
    }
  
  }
  </code></pre>
  
  <p>Lets say the Intent called Activity2 as <code>listActivities.get(0)</code></p>
  
  <pre><code>Activity2 extends MainActivity
  </code></pre>
  
  <p>Then another activity gets called, lets say ActivityNext</p>
  
  <p>In <code>ActivityNext extends Activity2</code></p>
  
  <pre><code>Intent intent = new (this, listActivities.get(1))
   startActivity(intent);
  </code></pre>
  
  <p>Gets called.
  The problem is since the listActivities is being shuffled many times through the life cycle </p>
  
  <pre><code>listActivities.get(1)
  </code></pre>
  
  <p>Could end up being Activity2 again and I don't want that to happen. </p>