title: Android: Handlers within Fragments *.post()?
body: <p>I am migrating code from a monolithic activity to a fragment / pager setup prescribed by the Big Nerd Ranch (CriminalIntent ch 21, <a href="https://www.bignerdranch.com/solutions/AndroidProgramming2e.zip" rel="nofollow">https://www.bignerdranch.com/solutions/AndroidProgramming2e.zip</a> ).  Great book BTW :)</p>
  
  <p>In doing so I am adding the following code below to the fragment CrimeCameraFragment to replace the camera photo recording with an audio recording.  When doing so, the Handler I'm trying to use doesn't have access to .post for some reason "error: cannot find symbol method post"?</p>
  
  <pre><code>public class Whatever extends fragment{
  
  the onCreateView code{
  button.setOnClickListener(...){
      audioRecord.startRecording();
      mHandler.post(updateTimerThread);
      };
  </code></pre>
  
  <p>then it has the following timerTask:</p>
  
  <pre><code>//timer code ---------------------------------------------------------------------
  public TimerTask updateTimerThread = new TimerTask(){
      public void run(){
          currentTime = SystemClock.uptimeMillis();
          elapsedTime = currentTime - startTime;
          if(elapsedTime&lt; recordingDurationInMilliseconds)
          {
              //First we read the audio buffer -----------
              int bufferRead = audioRecord.read(buffer, 0, readBufferSize);
              double dataDbl = processData(buffer, bufferRead);
  
              //Put the data and time stamp into arrays
              dataArray.add(dataDbl);
              timeArray.add(elapsedTime);
  
              //then fire up a new runnable
              mHandler.postDelayed(this, delayMillis);
          }
          else //if elapsed time is &gt; max record time
          {
              stopRecording();
          };
      }
  };
  </code></pre>
  
  <p>The handler is null to start</p>
  
  <pre><code>private Handler mHandler = null;
  </code></pre>
  
  <p>then has auto generated code later:</p>
  
  <pre><code>mHandler = new Handler() {
              @Override
              public void close() {}
  
              @Override
              public void flush() {}
  
              @Override
              public void publish(LogRecord record) {}
          };
  </code></pre>
  
  <p>Any idea where my Handler.post functionality went?</p>
  
  <p>Thanks!</p>