-
-
Notifications
You must be signed in to change notification settings - Fork 3
Open
Description
Method: navigateToPreferredDestination() in MainActivity.java
Description:
A race condition occurs when the navigateToPreferredDestination() method is called before the fragment is fully attached to the activity. This causes an IllegalStateException 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 with IllegalStateException: 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