title: Auto-generate random number every 30 sec on Android
body: <p>I want my program to auto generate random number every 30 sec when I hit the generate button, Question is how to do that in my code?</p>
  
  <pre><code>public class MainActivity extends Activity {
  
      @Override
      protected void onCreate(Bundle savedInstanceState) {
          super.onCreate(savedInstanceState);
          setContentView(R.layout.activity_main);
  
          final Random myRandom = new Random();
  
  
          Button buttonGenerate = (Button)findViewById(R.id.generateme);
          final TextView textGenerateNumber = (TextView)findViewById(R.id.generatenumber);
  
          buttonGenerate.setOnClickListener(new OnClickListener(){
  
              @Override
              public void onClick(View v) {
                  ArrayList&lt;Object&gt; Arry1 = new ArrayList&lt;Object&gt;();
                  for(int i=0;i&lt;1;i++){
                      ArrayList&lt;Integer&gt; Arry = new ArrayList&lt;Integer&gt;();
                      for(int k=0;k&lt;7;k++){
                          Arry.add(myRandom.nextInt(10));
                      }
                      Arry1.add(Arry);
                  }
                  textGenerateNumber.setText(String.valueOf(Arry1));
              }
          });  
      }
  }
  </code></pre>