I am using this BackButtonHandler based on a gist ...
# compose
v
I am using this BackButtonHandler based on a gist that Adam had shared earlier. I just started trying to use the navigation library in my app but I would still need this handler for taking care of some non-navigation use case. I see this error when I try to use this
BackButtonHandler
on a screen that was routed through the
NavHostController
. Is there a more graceful way to making these work together?
Copy code
java.lang.ClassCastException: androidx.navigation.NavBackStackEntry cannot be cast to androidx.appcompat.app.AppCompatActivity
        at com.airbnb.android.showkase.ui.ShowkaseCategoriesScreenKt.ShowkaseCategoriesScreen(ShowkaseCategoriesScreen.kt:85)
        at com.airbnb.android.showkase.ui.ShowkaseBrowserAppKt$ShowkaseBodyContent$1$1.invoke(ShowkaseBrowserApp.kt:160)
        at com.airbnb.android.showkase.ui.ShowkaseBrowserAppKt$ShowkaseBodyContent$1$1.invoke(Unknown Source:13)
        at androidx.compose.runtime.internal.ComposableLambda.invoke(ComposableLambda.kt:153)
        at androidx.compose.runtime.internal.ComposableLambda.invoke(Unknown Source:10)
        at androidx.navigation.compose.NavHostKt$NavHost$5$1.invoke(NavHost.kt:123)
        at androidx.navigation.compose.NavHostKt$NavHost$5$1.invoke(Unknown Source:10)
        at androidx.compose.runtime.internal.ComposableLambda.invoke(ComposableLambda.kt:144)