title: android updating seekbar with handler and runnable
body: <p>I fixed my issue by adding "seekHandler.post(updateSeekBarTime);" right below where I initialize the handler.</p>
  
  <p>I'm not getting errors, however my code doesn't seem to be working and I'm not to sure why. Any help would be appreciated. I'm trying to have a seekbar that moves as the media player plays it's file. I've been trying to figure out for a couple hours what's wrong and I'm stumped. here's my code:</p>
  
  <pre><code>public class SongsFragment extends Fragment {
  
      private ListView songListView;
      private ArrayList&lt;Song&gt; songList;
      private MediaPlayer mp = new MediaPlayer();
  
      private TextView textView;
      private Button pause;
      private SeekBar seekBar;
  
      private Handler seekHandler;
  
      @Override
      public View onCreateView(LayoutInflater inflater, ViewGroup container,
                               Bundle savedInstanceState) {
  
          songList = getSongList();
          Collections.sort(songList);
  
          View rootView = inflater.inflate(R.layout.songs_layout, container, false);
          songListView = (ListView) rootView.findViewById(R.id.listSongs);
          songListView.setAdapter(new SongAdapter(this.getActivity(), songList));
  
          pause = (Button) rootView.findViewById(R.id.buttonPause);
          textView = (TextView) rootView.findViewById(R.id.textView);
          seekBar = (SeekBar) rootView.findViewById(R.id.seekBar);
  
          songListView.setOnItemClickListener(new AdapterView.OnItemClickListener() {
              @Override
              public void onItemClick(AdapterView&lt;?&gt; parent, View view, int position, long id) {
                  Song song = (Song) parent.getItemAtPosition(position);
                  textView.setText(song.getName()+" - "+song.getArtist());
  
                  try {
                      mp.reset();
                      mp.setDataSource(song.getPath());
                      mp.prepare();
                      mp.start();
                  } catch (Exception e) {
                      e.printStackTrace();
                  }
  
                  Toast.makeText(getActivity(), song.getPath(), Toast.LENGTH_SHORT).show();
              }
          });
  
          pause.setOnClickListener( new View.OnClickListener() {
              @Override
              public void onClick(View v) {
                  if (mp.isPlaying()) {
                      mp.pause();
                      pause.setText("play");
                  } else {
                      mp.start();
                      pause.setText("pause");
                  }
              }
          });
  
          seekHandler = new Handler();
  
          return rootView;
      }
  
      //handler to change seekBarTime
      private Runnable updateSeekBarTime = new Runnable() {
          public void run() {
              seekBar.setMax(mp.getDuration());
              seekBar.setProgress(mp.getCurrentPosition());
              seekHandler.postDelayed(updateSeekBarTime, 1000);
          }
      };
  
      public ArrayList&lt;Song&gt; getSongList() {
          //not important
      }
  }
  </code></pre>