Generating random data and passing information between activities
<p>Im currently working on Quiz-program. The program has several different question cathegories. Each category have several questions that should be randomized and also fill the criteria that it should not appear more than once.</p>

<p>Each category is implemented as an activity, and the data is passed between activies in a bundle.</p>

<p>The main activity implements a class that generates the random categories, and that class keeps track on how many question categories that are used. The same code that are used for generating questions are used for generating question categories.</p>

<p>Now, sometimes it happens that a question does appear more than once. I figure there could be 2 possible causes for this problem. There might be a problem with how I generate the questions or the data is set to zero somewhere else in the code.</p>

<p>My random algoritm for generating one questions looks like this:</p>

<pre><code>    while (ProgrammingQuestionsIndexArray[ProgrammingQuestionsIndex] == 1) {
        ProgrammingQuestionsIndex = randomGenerator.nextInt(MAX);
        counter = 0;
        for(int i=0; i&lt;ProgrammingQuestionsIndexArray.length; i++) {
            if(ProgrammingQuestionsIndexArray[i] == 1)
                counter++;
        }
        if(counter == ProgrammingQuestionsIndexArray.length) {
            for(int i=0; i&lt;ProgrammingQuestionsIndexArray.length; i++)
                ProgrammingQuestionsIndexArray[i] = 0;
            break;
        }   
    }
</code></pre>

<p>The ProgrammingQuestionsIndexArray is where I store if the questions already been used or not.
ProgrammingQuestionsIndex is the variable for the random generated question.
MAX is the number of maximal number of questions that are set in the category.</p>

<p>Also, the reason why I ask it here, is because I suspect that there are another reason rather than the algoritm why the random function doesnt work.</p>

<p>Thanks in advance!</p>
