title: How can I keep the timer running when I navigate to different fragment with bottom navigation in my android app?
body: <p>The fragment gets destroyed and the timer resets to 00:00 when I navigate using bottom navigation.
  I have used Chronometer.
  I tried <em>retainInstance=true</em> but it only helps when screen is rotated.</p>
  <p><strong>MainActivity.kt</strong></p>
  <pre><code>class MainActivity : AppCompatActivity() {
      private lateinit var navController: NavController
  
  
  
      override fun onCreate(savedInstanceState: Bundle?) {
          super.onCreate(savedInstanceState)
          setContentView(R.layout.activity_main)
          val navHostFragment =supportFragmentManager.findFragmentById(R.id.nav_host_fragment) as NavHostFragment
          navController =navHostFragment.findNavController()
  
          bottom_nav.setupWithNavController(navController)
  
      }
  
  } 
  </code></pre>
  <p><strong>TimerFragment.kt</strong></p>
  <pre><code>class TimerFragment : Fragment(R.layout.fragment_timer) {
  
      override fun onViewCreated(view: View, savedInstanceState: Bundle?) {
  
          super.onViewCreated(view, savedInstanceState)
         
            //code
          
      }
  
       //Few functions
  }
  </code></pre>