Billy Newman
04/03/2023, 2:27 PMBilly Newman
04/03/2023, 2:30 PMoverride fun onCreate(savedInstanceState: Bundle?) {
super.onCreate(savedInstanceState)
// handle the file share intent
viewModel.intent.observe(this) { intent ->
navController.handleDeepLink(intent)
}
// This will check the incoming intent for a file share
viewModel.setIntent(intent)
setContent {
val bottomSheetState = rememberModalBottomSheetState(
initialValue = ModalBottomSheetValue.Hidden,
skipHalfExpanded = true
)
val bottomSheetNavigator = remember {
BottomSheetNavigator(sheetState = bottomSheetState)
}
navController = rememberNavController(bottomSheetNavigator)
MainScreen(
navController = navController,
bottomSheetNavigator = bottomSheetNavigator
)
}
}
ModalBottomSheetLayout(bottomSheetNavigator) {
Scaffold(...) { paddingValues ->
NavHost(
navController = navController,
startDestination = "main", // Start at main, this will happen after deep link handler from MainActivity
modifier = Modifier.padding(paddingValues)
) {
...
}
}
Is there a “recipe” for this? Maybe only handle deep links in this fashion if the app is running, and if not running just pass the intent to the MainScreen on construction? Feels wrongIan Lake
04/03/2023, 2:40 PMBilly Newman
04/03/2023, 2:46 PM<intent-filter>
<action android:name="android.intent.action.VIEW" />
<action android:name="android.intent.action.SEND" />
<category android:name="android.intent.category.DEFAULT" />
<data android:scheme="content" />
<data android:mimeType="application/octet-stream" />
</intent-filter
I know how handle that in my MainActivity, however getting the nav controller to handle a content uri sounds like what I am missingIan Lake
04/03/2023, 3:46 PMaction
and mimeType
instead of uriPattern
Billy Newman
04/03/2023, 4:05 PMBilly Newman
04/03/2023, 4:30 PMIan Lake
04/03/2023, 4:34 PMContentResolver.openInputStream
works to read the contents of that file in every case thoughBilly Newman
04/03/2023, 5:07 PMBilly Newman
04/03/2023, 5:18 PMval intent = backstackEntry.arguments?.getParcelable(NavController.KEY_DEEP_LINK_INTENT, Intent::class.java)
Ian Lake
04/03/2023, 5:56 PMKEY_DEEP_LINK_INTENT
is sent along through arguments