I have added Bottom Navigation View for my app but I need the Bottom Navigation View between activities instead of fragment so I have added this code to Java for all my 3 ac
To anyone still looking for this, @javazian's answer of extending each activity is real overkill in my opinion.
A much more succinct solution is to retrieve the nav menu and manually check the relevant menu item.
Note in the example below, INSERT_INDEX_HERE needs to be replaced with the index of the menu item, (e.g. the menu item on the far left would have index 0).
@Override
protected void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
setContentView(R.layout.activity_connections);
BottomNavigationView navigation = (BottomNavigationView) findViewById(R.id.navigation);
navigation.setOnNavigationItemSelectedListener(mOnNavigationItemSelectedListener);
// Ensure correct menu item is selected (where the magic happens)
Menu menu = navigation.getMenu();
MenuItem menuItem = menu.getItem(INSERT_INDEX_HERE);
menuItem.setChecked(true);
}