Access Back Icon (Android Navigation Component)
When using Android Navigation Component, Navigation host, the back button is automatically generate,…
But in my case, I can’t access it
So I type this code to my “Activity”
There are 2 overrided function there “onCreate()” and “onOptionItemSelected()”.
The onCreate() function job is to handle the navigation controller, and
The onOptionsItemSelected() function is to handle the clicked Option Item, but don’t forget to insert the “when” statement, so that it listen to back icon. I don’t know for sure, but android studio seems to give “android.R.id.home” as back icon’s id.