'Android Navigation Component jump a few steps in graph at once
I use navigation component, and I need to in certain situations navigate a few steps forward at once. For example FragmentA has direction to FragmentB and the later has direction to FragmentC. My goal is to in certain situations jump directly to FragmentC but have the normal navigation graph, so when user comes back from FragmentC he/she appears on FragmentB as if he appeared in FragmentC by one by one navigation.
I found that NavDeepLinkBuilder can solve my problem with the following:
val pendingIntent = NavDeepLinkBuilder(context)
.setGraph(R.navigation.my_graph)
.addDestination(R.id.fragmentA_destination,
.addDestination(R.id.fragmentB_destination)
.setComponentName(MyActivity::class.java)
.createPendingIntent()
pendingIntent.send()
It actually does what I want but with 2 problems:
- It finishes the calling activity, and I don't know if I can prevent it from finishing it.
- This does not seem to be right at all, as
PendingIntentis not designed to be used to navigate inside my own application, so what I do above seems to be a sort of hack.
So how else can I achieve the same result without using this PendingIntent mechanism?
Solution 1:[1]
If you have generic content and don't want to use linguistic processing, you can use a generic analyzer like the Whitespace analyzer. See
https://docs.microsoft.com/en-us/azure/search/index-add-custom-analyzers#built-in-analyzers
How searches for single or multiple words work is determined by the searchMode parameter. The recommended practice is to use all, instead of any. When you specify more terms, you are more specific and you want fewer (more precise) results.
You can specify multi-word queries where individual search terms are fuzzy by using the tilde syntax. E.g. to do a fuzzy search for joe but exact match on blogs you could something like:
joe~ blogs
You can also control how fuzzy you want it to be. See
https://docs.microsoft.com/en-us/azure/search/query-lucene-syntax#bkmk_fuzzy
PS: From your use case it sounds like proximity matching is also something you could consider using:
https://docs.microsoft.com/en-us/azure/search/query-lucene-syntax#bkmk_proximity
Sources
This article follows the attribution requirements of Stack Overflow and is licensed under CC BY-SA 3.0.
Source: Stack Overflow
| Solution | Source |
|---|---|
| Solution 1 | Dan Gøran Lunde |
