android-jetpack-navigation
Sharing viewModel within Jetpack Compose Navigation
Consider passing your activity to viewModel() fun as viewModelStoreOwner parameter since ComponentActivity implements ViewModelStoreOwner interface: val viewModel: ConversionViewModel = viewModel(LocalContext.current as ComponentActivity) This code will return the same instance of ConversionViewModel in all your destinations.
How to navigate from a composable to an activity or a fragment in Jetpack Compose?
In newer version of compose use LocalContext. In older versions (1.0.0-alpha08 and before) use AmbientContext: @Composable fun MainScreen() { val context = LocalContext.current Button(onClick = { context.startActivity(Intent(context, ListActivity::class.java)) }) { Text(text = “Show List”) } }
CreationExtras must have a value by `SAVED_STATE_REGISTRY_OWNER_KEY`
@Dragan.T ‘s answer is correct. Adding implementation “androidx.navigation:navigation-compose:2.5.3 Solved my problem. As for why we need to add, I am not so sure. Edit: Be sure to replace 2.5.3 with latest version.
Pass Parcelable argument with compose navigation
Warning: Ian Lake is an Android Developer Advocate and he says in this answer that pass complex data structures is an anti-pattern (referring the documentation). He works on this library, so he has authority on this. Use the approach below by your own. Edit: Updated to Compose Navigation 2.4.0-beta07 Seems like previous solution is not … Read more
Compose-Navigation: Remove previous composable from stack before navigating
In Jetpack Compose 1.0.0 to navigate and remove the previous Composable from the back stack You can use: navController.navigate(Screens.Login.name) { popUpTo(Screens.Splash.name) { inclusive = true } } The above code will navigate from the Splash screen to Login and will pop everything up, including the Splash screen. Navigate to a composable – docs
Android studio build error in navigation component, action is not abstract and does not implement abstract member actionID
I had this problem too. Until they release the fix. Please try this: plugins { id(“androidx.navigation.safeargs”) } instead of plugins { id(“androidx.navigation.safeargs.kotlin”) }