Q:

BottomNavigationView - How to get selected menu item? 

I used BottomNavigationView to switch fragments.  How to get currently selected menu item, to prevent reopening fragment ?  
        BottomNavigationView bottomNavigationView = (BottomNavigationView)
                findViewById(R.id.bottom_navigation);

        bottomNavigationView.setOnNavigationItemSelectedListener(
                new BottomNavigationView. OnNavigationItemSelectedListener() {
                    @Override
                    public boolean onNavigationItemSelected(@NonNull MenuItem item) {
                        switch (item.getItemId()) {
                            case R.id.action_1:
                                // open fragment 1
                                break;
                            case R.id.action_2:
                                // open fragment 2
                                break;
                            case R.id.action_3:
                                // open fragment 3
                                break;
                        }
                        return false;
                    }
                });
    }

A:

Get selected item at first and then getMenu().findItem(int itemId)
bottomNavigationView.getMenu().findItem(bottomNavigationView.getSelectedItemId())

A:

Solution:
private int getSelectedItem(BottomNavigationView bottomNavigationView) {
    Menu menu = bottomNavigationView.getMenu();
    for (int i = 0; i < bottomNavigationView.getMenu().size(); i++) {
        MenuItem menuItem = menu.getItem(i);
        if (menuItem.isChecked()) {
            return menuItem.getItemId();
        }
    }
    return 0;
}

