Uh oh!
There was an error while loading.Please reload this page.
- Notifications
You must be signed in to change notification settings - Fork3
Open
Description
Method:navigateToPreferredDestination() in MainActivity.java
Description:
A race condition occurs when thenavigateToPreferredDestination() method is called before the fragment is fully attached to the activity. This causes anIllegalStateException and app crash.
Steps to Reproduce:
- Launch the app
- Quickly navigate between screens during app startup
- Call
navigateToPreferredDestination()before fragment lifecycle completes
Expected Behavior:
Navigation should wait for fragment to be fully attached or handle gracefully.
Actual Behavior:
App crashes withIllegalStateException: Fragment not attached to activity
Proposed Fixed
Add this condition right before navigation:
if (getLifecycle().getCurrentState().isAtLeast(Lifecycle.State.RESUMED)) {navController.navigate(preferredDestination,null,options);}
Metadata
Metadata
Assignees
Labels
No labels