Hey guys, got a question about Compose navigation ...
# compose
r
Hey guys, got a question about Compose navigation and intents: I’m currently accepting pdf file types so I’ve set the following in
Manifest.xml
file
Copy code
<intent-filter>
                <action android:name="android.intent.action.SEND" />
                <category android:name="android.intent.category.DEFAULT" />
                <data android:mimeType="application/pdf" />
            </intent-filter>
And on my MainActivity, I can see the intent with the URI of the pdf file once user send it to my app. Compose navigation is under official google library. Question is, how can I handle the uri with navigation in Compose? Is there a way to automatize the process? All I’ve been able to do is adding a
LaunchedEffect(intent) { ... navigator.navigate(...) }
but I definitely dislike the solution… Is there a known/default approach for these cases?
I’ve tried this known solution but it doesn’t work… I don’t know what I’m missing 🤔
Copy code
DisposableEffect(Unit) {
    val listener = Consumer<Intent> {
        Log.d("AppStart", "onNewIntent: $it")
    }
    addOnNewIntentListener(listener)
    onDispose { removeOnNewIntentListener(listener) }
}
i
The
navDeepLink
API explained in the docs also supports actions and mimeTypes, not just uriPatterns: https://developer.android.com/develop/ui/compose/navigation#deeplinks
r
Aha I see now in the docs! I didn’t expect it’d be that way. And I see the
mimeType
option in
NavDeepLinkDslBuilder
. Thank you Ian!!
i
How were you expecting to handle a deep link to a destination other than the deep link APIs?
r
just wasn’t aware of deeplink also handling mime types. I haven’t had the chance to work on deeplinks with mime type