Android App Architecture & Navigation

108056ccba92f98fdbbabad534537573?s=47 Bryan Herbst
September 04, 2018

Android App Architecture & Navigation

A look into the new navigation architecture component and how it fits with Fragments and Activites

108056ccba92f98fdbbabad534537573?s=128

Bryan Herbst

September 04, 2018
Tweet

Transcript

  1. 3.
  2. 11.

    Activity Entry point to your application Has a Window Has

    a lifecycle Responds to configuration changes
  3. 12.

    Activity Entry point to your application Has a Window Has

    a lifecycle Responds to configuration changes ActivityManager handles back stack
  4. 13.

    Activity Layout inflation View manipulation Click handlers Animations Navigation Menu

    creation Menu item callbacks Database calls Networking calls Disk I/O Sensor input Geolocation
  5. 18.
  6. 29.
  7. 88.

    Principles Navigation is a stack Up never exits the app

    Up = Back within your app Deep linking should yield the same stack
  8. 104.

    Destinations: Deep link Destinations can have deep links <fragment android:id="@+id/home”

    android:name="com.example.HomeFragment" android:label="fragment_home"> <deepLink app:uri="http://example.com/detail"/> </fragment>
  9. 105.

    Actions: Animations Actions can have transition animations <action android:id="@+id/action_home_to_detail" app:destination="@id/detail"

    app:popEnterAnim="@anim/slide_in_left" app:popExitAnim="@anim/slide_out_right" app:enterAnim="@anim/slide_in_right" app:exitAnim="@anim/slide_out_left"/>
  10. 106.

    Actions: back stack Each action can define its own behavior

    <action android:id="@+id/home_to_details" app:destination="@id/details” app:popUpTo="@id/splash” app:popUpToInclusive="false" />
  11. 112.
  12. 116.

    What’s missing Some integration with common elements like bottom navigation

    Shared element transitions Nested navigation graphs
  13. 117.

    What’s missing Some integration with common elements like bottom navigation

    Shared element transitions Nested navigation graphs Result data (e.g. startActivityForResult())
  14. 123.

    Single Activity Set up navigation graph Each Fragment is a

    destination Every transaction is an action
  15. 124.

    Single Activity Set up navigation graph Each Fragment is a

    destination Every transaction is an action Define arguments
  16. 125.

    Single Activity Set up navigation graph Each Fragment is a

    destination Every transaction is an action Define arguments Replace transactions with NavController.navigate()
  17. 127.

    Multiple activities Start by making a graph for each Activity

    If you want a single Activity, combine Activities one screen at a time