I am trying to navigate from an second activity to specific fragment in Bottom Navigation View in first activity by using Up(<-) back Button. i have tried code
val actionBar = supportActionBar
actionBar!!.setDisplayHomeAsUpEnabled(true)
but,while placing parent activity in Manifest File,it wont show the fragment which is required by me.it is going to Home fragment in the 1st activity.
This is my fragment code in First Activity
btm = findViewById(R.id.navigation) as BottomNavigationView
btm.setOnNavigationItemSelectedListener { item ->
var selectedFragment: Fragment? = null
when (item.itemId) {
R.id.navigation_home ->
selectedFragment = ReferFragment.newInstance()
R.id.navigation_dashboard ->
selectedFragment = AccountFragment.newInstance()
R.id.navigation_notifications ->
selectedFragment = ProfileFragment.newInstance()
}
var ft: FragmentTransaction =
supportFragmentManager.beginTransaction()
ft.replace(R.id.fragment_container, selectedFragment)
ft.commit()
true
}
var ft: FragmentTransaction = supportFragmentManager.beginTransaction()
ft.replace(R.id.fragment_container, ReferFragment.newInstance())
ft.commit()
i want to goto 3rd fragment while clicking on UP backButton in second activity. THANK YOU