My MainActivity has a bottom navigation which defaults to the first item. Depending on data received via intent, I'd like for the selected item to change. I'm using the following code on the MainActivity's OnCreate method:
if (getIntent().getExtras() != null) {
String deepLink = getIntent().getExtras().getString("type");
if (deepLink.equals("mydata")) {
if (loggedIn) {
bottomNav.setSelectedItemId(R.id.myitem);
}
}
} else {
setTitle("First");
getSupportFragmentManager().beginTransaction().replace(R.id.fragment_container, new FirstFragment(), "First").commit();
}
This works initially but after a second or two, the selected item goes back to being the first. What can I do so that the selected item remains active after loading?