title: How to use android navigation without binding to UI in ViewModel (MVVM)?
body: <p>I am using android navigation that was presented at Google I/O 2018 and it seems like I can use it by binding to some view or by using <code>NavHost</code> to get it from Fragment. But what I need is to navigate to another specific view from ViewModel from my first fragment depending on several conditions. For <code>ViewModel</code>, I extend <code>AndroidViewModel</code>, but I cannot understand how to do next. I cannot cast <code>getApplication</code> to Fragment/Activity and I can't use <code>NavHostFragment</code>. Also I cannot just bind navigation to <code>onClickListener</code> because the <code>startFragment</code> contains only one <code>ImageView</code>. How can I navigate from <code>ViewModel</code>?</p>
  
  <pre><code>class CaptionViewModel(app: Application) : AndroidViewModel(app) {
  private val dealerProfile = DealerProfile(getApplication())
  val TAG = "REGDEB"
  
  
   fun start(){
      if(dealerProfile.getOperatorId().isEmpty()){
          if(dealerProfile.isFirstTimeLaunch()){
              Log.d(TAG, "First Time Launch")
              showTour()
          }else{
              showCodeFragment()
              Log.d(TAG, "Show Code Fragment")
  
          }
      }
  }
  
  private fun showCodeFragment(){
      //??
  }
  
  private fun showTour(){
      //??
  }
  
  }
  </code></pre>
  
  <p>My Fragment</p>
  
  <pre><code>class CaptionFragment : Fragment() {
  private lateinit var viewModel: CaptionViewModel
  private val navController by lazy { NavHostFragment.findNavController(this) }
  
  override fun onCreateView(inflater: LayoutInflater, container: ViewGroup?, savedInstanceState: Bundle?): View {
      viewModel = ViewModelProviders.of(this).get(CaptionViewModel::class.java)
      return inflater.inflate(R.layout.fragment_caption, container, false)
  }
  
  
  override fun onActivityCreated(savedInstanceState: Bundle?) {
      super.onActivityCreated(savedInstanceState)
  
      viewModel.start()
  
  }
  
  }
  </code></pre>
  
  <p>I want to keep logic of navigation in ViewModel</p>