https://kotlinlang.org logo
#android
Title
# android
j

JD

11/19/2019, 5:02 AM
Question on Android navigation library aka single activity pattern. Is it intended to have your entire app defined by the single activity or would it actually be better to have multiple navigation for various different modules like authentication, home, may be a product list (including flows till product checkout). Has anyone used it in production app so far. Any pointers would be helpful.
stackoverflow 2
google 2
a

Abhishek Bansal

11/19/2019, 5:32 AM
We have been using a mixed pattern in production. Some of our new modules are on this. While older modules follow activity pattern.
👌 1
s

Steve

11/19/2019, 5:32 AM
Usually what you'd want to do is limit the Activities to entry points into the app
☝️ 1
👍 4
From there, you can use the Navigation Components to navigate inside that Activity
j

JD

11/19/2019, 12:18 PM
@Abhishek Bansal meaning you have multiple navigation hierarchy or flows and you link them based on through activities is it. @Steve generally there would be a single entry point into the app. I am assuming the case when you say entry points as number of launcher icons. Is that correct understanding or do you mean to apply deeplinks into your app? Can you please elaborate. Also, having multiple segregated navigation has any sort of impacts on deep linking within a particular flow. As navigation library provides that out of the box. However if there are multiple navigation has anyone managed to link those
a

Abhishek Bansal

11/19/2019, 12:44 PM
We have multiple Navigation Architecture flows in our app yes.
They are launched when corresponding Activity is launched
c

Cyberpunk Keanu

11/19/2019, 12:53 PM
I'm also using Navigation Component with 5 activities in our app. Authentication (Login, SignUp, Forgot Password,etc.), Main Navigation (Switching between Different Navigation Fragments on the main page), Transactions Activity (Houses a set of common flows of fragments), Payments(Include Transactions, Cart, OTP, etc.) The general idea is to keep the number Activities less & wrap all the general flow of you app's pages as fragments.
👍 1
j

JD

11/19/2019, 1:45 PM
Perfect @Cyberpunk Keanu and @Abhishek Bansal very helpful. Do you guys have deep links in the app where you need to create an entire navigation stack eg. Launch directly one of transaction activity from sample above so you need a hierarchy of Main Navigation -> Transaction Activity so up or back will perform appropriate action. Was it too much of a work around or utilized the navigation framework methods for performing something like this in any way
s

Steve

11/19/2019, 5:32 PM
@JD I meant different places that a user could get into your app. The Launcher Icon is one, through a notification could be another, and if you expose intents for other apps to use could be yet another.
👍 1
a

Abhishek Bansal

11/20/2019, 6:51 AM
@JD we have some app links in one of the navigation flow but they are rather simple. They do not go through any other activity.
c

Cyberpunk Keanu

11/20/2019, 7:56 AM
@JD Our app has deep links yes, but they all lead to the same MainContent Activity, & then based on which type of notification was recieved, the fragment content to be display is set. Basically all deep links point to Main Activity for different fragments. That's the beauty of Navigation Architecture.
j

JD

11/20/2019, 6:25 PM
Yes that's where I fear for a below use case using multiple navigation graphs in app. Eg. I have one activity Home (Containing its own navigation graph) I have second activity Promotion (Containing its own navigation graph) Now with deep link I am want it to go and create hierarchy like below: - Home - Promotion - Promotion Detail So that when user does Up or Back it goes back to Promotion and eventually back to Home. Now since navigation graph doesn't allow sharing the deeplinks between them wouldn't it result in either do this or do that or say do it yourself kind of thing?
4 Views