Only allow one instance when navigate with NavController

Add a check before navigating to the destination as it would not add a new instance.

class A: AppCompatActivity {

    fun onCreate(...) {
        // ...While navigating
        if (navController.currentDestination?.id != desiredDestination?.id) {
            navController.navigate(desiredDestination)
        }
        // ...else do nothing
    }
}

Callback from NavController: https://developer.android.com/reference/androidx/navigation/NavController#addOnDestinationChangedListener(androidx.navigation.NavController.OnDestinationChangedListener)

Leave a Comment

Hata!: SQLSTATE[HY000] [1045] Access denied for user 'divattrend_liink'@'localhost' (using password: YES)