Navigation in Modular Applications with Deep Linking

Navigation in Modular Applications with Deep Linking

Android engineering has come a long way. Nowadays most applications are modularized to a certain degree - to combat high compile times, enforce separation of concerns or to group code based on certain scopes.

In this talk we will take a look at navigation in modularized apps. Navigation in Android can be done explicitly by passing the class variable or implicit by sending an Intent with a certain configuration. Since modularization is supposed to simplify our dependency graph, we will take a closer look at deep linking as a navigation pattern and compare different approaches like Intent filter, a custom deeplink processor or the Android Jetpack Navigation component.

088b337d298da771eb119172843f8f49?s=128

Damian Burke

July 03, 2019
Tweet

Transcript

  1. Navigation in Modular Applications Damian Burke Onefootball @damian2048 damian-burke

  2. Modularization

  3. Single Module app Easy access to everything. Scoping with modifiers

    (public, private, protected, …) and packages.
  4. Modularization by Layer app domain data ... Layers work on

    a need-to-know basis. Easy to build for different targets (mobile, wearOS, TV).
  5. Modularization by Feature app dashboard newsfeed profile core Feature scopes

    allow parallel work with less conflicts.
  6. Modularization Matrix app dashboard-ui core dashboard-domain dashboard-data newsfeed-ui dashboard-domain dashboard-data

    profile-ui profile-domain profile-data
  7. Navigation

  8. Multi-Activity and Intent

  9. Fragment Transactions

  10. View Groups and Views Or use one of the view-based

    frameworks like… - Conductor - Scoop
  11. AndroidX Navigation Component

  12. Deep Linking

  13. How to Link URI - Uniform Resource Identifier URI Scheme:

    RFC 3986
  14. Surfing the web… Platform independent.

  15. Deep Linking

  16. Deep Linking Scheme: myapp Host: profile Path: 12345

  17. Deep Linking in Action

  18. Manually via Android Manifest

  19. Deeplink Processor Single Activity to catch-all deeplinks.

  20. Deeplink Processor Single Activity to catch-all deeplinks.

  21. Deeplink Processor Single Activity to catch-all deeplinks. Passes the link

    on to a handler.
  22. Deeplink Processor Single Activity to catch-all deeplinks. Passes the link

    on to a processor.
  23. Annotation-based Deeplink Processor https://github.com/airbnb/DeepLinkDispatch

  24. Annotation-based Deeplink Processor https://github.com/airbnb/DeepLinkDispatch

  25. AndroidX Navigation Component

  26. Modularization + Navigation

  27. Modularization by Feature app dashboard profile core All possible targets

    can be made available by adding the dependency. newsfeed
  28. Modularization by Feature… with Dynamic Delivery app dashboard profile core

    Sometimes the newsfeed module is there, sometimes it’s not. newsfeed
  29. Detour: Dynamic Features app dashboard profile core Google introduced Dynamic

    Features to further modularize app delivery. Next step after App Bundles. Reverses the module-dependency. newsfeed (injecting functionality)
  30. Detour: Dynamic Features app dashboard profile core App has no

    compile-time dependency on newsfeed. App (or base) doesn’t know about Android components. newsfeed (injecting functionality)
  31. Multi-Activity and Intent Now requires a String instead of the

    class name.
  32. Fragment Transactions Now require reflection to create the Fragment instead

    of a simple constructor or method call.
  33. Modularization + Deep Linking

  34. Modularization: The tough part with dynamic features Dynamic features are/can

    be added at runtime. Requires a dynamic navigation. Implementation details might be unknown. app dashboard profile core newsfeed ? ?
  35. Modularization: The tough part with dynamic features We could use

    fully qualified class names and create Intents, but that introduces tight coupling between otherwise independent dynamic features. app dashboard profile core newsfeed ?
  36. Modularization: The tough part with dynamic features Fully qualified class

    names as Strings… just doesn’t feel right. dashboard newsfeed
  37. Deep Linking Implementation independent. Descriptive.

  38. Modularization: The tough part with dynamic features Deep Linking through

    via Intents as a decoupled navigation pattern. Good for a decoupled scenario. app dashboard profile core newsfeed intent: myapp://newsfeed/article/123
  39. Modularization: The tough part with dynamic features AndroidManifest is still

    merged. Intent-Filters are alive in dynamic features. Flexible and dynamic. app dashboard profile core newsfeed intent: myapp://newsfeed/article/123 intent-filter: myapp://newsfeed/{type}/{id}
  40. Modularization: The tough part with dynamic features AndroidManifest is still

    merged. Intent-Filters are alive in dynamic features. Flexible and dynamic. app dashboard profile core newsfeed intent: myapp://newsfeed/article/123 <deepLink app:uri="myapp://newsfeed" />
  41. What’s next?

  42. Modularization is hard. Take a look at other approaches. Navigation

    in Modular Applications with Deep Linking - https://blog.usejournal.com/navigation-in-modular-applicatio ns-with-deep-linking-6a599c11e487 Patterns for accessing code from dynamic feature modules - https://medium.com/androiddevelopers/patterns-for-accessi ng-code-from-dynamic-feature-modules-7e5dca6f9123 Plaid - https://github.com/android/plaid airbnb Deeplink Dispatcher - https://github.com/airbnb/DeepLinkDispatch AndroidX Navigation - https://developer.android.com/guide/navigation/
  43. Thank You Onefootball @damian2048 damian-burke (we’re hiring)