title: How do I return the value of an array of flags from a countdown timer in Android Studio?
body: <p>I have a count down timer, inside it it is the onTick method and inside that method there are several if statements. Now if I have set the flag array values in those if statements and want to return the value of the flags and check for them when I click a button, how do I do that?</p>
  <pre><code>the array ---&gt; int [] flag = {0,0,0}
  the timer ---&gt;  
  
  private void startTimer() {
          Log.println(Log.ASSERT, &quot;CHECK&quot;,&quot;Entered startTimer() method&quot;);
          millisInFuture = mTimeLeftInMillis;
          mCountDownTimer = new CountDownTimer(mTimeLeftInMillis, 1000) {
              @Override
              public void onTick(long millisUntilFinished) {
                  mTimeLeftInMillis = millisUntilFinished;
                  updateCountDownText();
                  final long millisPassed = millisInFuture - mTimeLeftInMillis;
                  progress = (int) (millisPassed * 100 / millisInFuture);
                  pb.setProgress(progress);
                  pb2.setProgress(0);
                  pb3.setProgress(0);
  
  
  /////////////////////////////////////////////////////////////////////////////////////////////////////////////////
                  //Key: 60 sec
                  if (millisInFuture == 480000) {
                      if (millisPassed &lt;= 60000 || (millisPassed &gt; 180000 &amp;&amp; millisPassed &lt;= 240000) || (millisPassed &gt; 300000 &amp;&amp; millisPassed &lt;= 360000 || (millisPassed &gt; 420000 &amp;&amp; millisPassed &lt;= 480000))) {
  //                        Animation animation = AnimationUtils.loadAnimation(tool1mode1.this, R.anim.fade_in);
  //                        stepupimage.setAnimation(animation);
                          Log.println(Log.ASSERT,&quot;CHECK&quot;,&quot;Check that the first if statement of key 60 is entered&quot;);
                          statusIfUp();
                          flag[0] = 1;
                          //stageUp(stageTime[0]);
                          upArrowAnimation();
                      } else if ((millisPassed &gt; 60000 &amp;&amp; millisPassed &lt;= 180000)) {
  //                        Animation animation = AnimationUtils.loadAnimation(tool1mode1.this, R.anim.fade_in);
  //                        stepdownimage.setAnimation(animation);
                          Log.println(Log.ASSERT,&quot;CHECK&quot;,&quot;Check that the second if statement of key 60 is entered&quot;);
                          statusIfDown();
                          flag[0] = 0;
                          flag[1] = 1;
                          flag[2] = 0;
                         // stageDown(stageTime[1]);
                          downArrowAnimation();
                      } else if ((millisPassed &gt; 240000 &amp;&amp; millisPassed &lt;= 300000) || (millisPassed &gt; 360000 &amp;&amp; millisPassed &lt;= 420000)){
  //                        Animation animation = AnimationUtils.loadAnimation(tool1mode1.this, R.anim.fade_in);
  //                        stepdownimage.setAnimation(animation);
                          Log.println(Log.ASSERT,&quot;CHECK&quot;,&quot;Check that the first if statement of key 60 is entered&quot;);
                          statusIfDown();
                          flag[0] = 0;
                          flag[1] = 0;
                          flag[2] = 1;
                        //  stageDown(stageTime[2]);
                          downArrowAnimation();
                      }
  
                  }
  
              @Override
          public void onFinish() {
  
              pb.setProgress(100); pb2.setProgress(0); pb3.setProgress(0);
              stage_timer.setVisibility(View.INVISIBLE);
              stage_timer.setVisibility(View.INVISIBLE);
              avd1.stop(); avd2.stop(); avd3.stop(); avd4.stop();
              //Vibration
              if (Build.VERSION.SDK_INT &gt;= 26) {
                  ((Vibrator) getSystemService(VIBRATOR_SERVICE)).vibrate(VibrationEffect.createOneShot(150, VibrationEffect.DEFAULT_AMPLITUDE));
                  Toast.makeText(tool1mode1.this, &quot;Done&quot;, Toast.LENGTH_SHORT).show();
              } else {
                  ((Vibrator) getSystemService(VIBRATOR_SERVICE)).vibrate(VibrationEffect.createWaveform(new long[]{150}, new int[]{VibrationEffect.EFFECT_CLICK}, -1));
              }
          }
      }.start();
  
  }
  </code></pre>
  <p>Now when I click the button inside its onClick method I call the startTimer() method to start my timer. What I want is to check the flag value while this timer is working, and based on the flag value I will call a method that I will pass a value to. The flags act as signals for a lack of better word. So how do I return the flag values in the onTick method inside the timer?</p>