title: How to stop audiotrack and audiorecord playback on back press in android?
body: <p>I have an <code>Activity</code> A and <code>Activity</code> B.</p>
  
  <p>In <code>Activity</code> A audio record and playback performs and on the press of back button audiotrack and audio record stops without any issue, but the main problem is in <code>Activity</code> B there is a video,when the footage of the video ends it moves back to <code>Activity</code> A.</p>
  
  <p>Now the issue is at this time when I press back button the voice playback starts, means audiotrack and audiorecord doesn't stops.</p>
  
  <p>I have gone through activity life cycle but i didn't got the desired <code>Activity</code>.</p>
  
  <pre><code>public void onBackPressed() {
  
      super.onBackPressed(); 
      Intent intent = new Intent(); 
      intent.addCategory(Intent.CATEGORY_HOME); 
      intent.setFlags(Intent.FLAG_ACTIVITY_NEW_TASK); 
      intent.setAction(Intent.ACTION_MAIN); 
      startActivity(intent); 
      m_aboutOnyx.stop(); 
      timer.cancel(); 
      if(c_b_left == 1 || c_b_Right == 1 || c_b_fart ==1 || c_b_transperant ==1 ||c_b_food ==1 ||c_b_thunder ==1 || c_b_thumbs_up ==1){ 
          timer1.cancel();     
      } 
      isRecording = false; 
      track.stop(); 
      track.release(); 
      record.stop(); 
      record.release(); 
      this.finish(); 
  
  }
  </code></pre>