Upgrade to Pro — share decks privately, control downloads, hide ads and more …

Introduction to Instant Apps

Introduction to Instant Apps

From DroidconPL '17 http://droidcon.pl/#/talks/30
Unfortunately due to Speaker Deck limitations, you have to download the PDF version to click the links.

Marcin Koziński

December 02, 2017

Transcript

49 slides
  1. Single-feature instant app .java :app .java .xml .png apply plugin:

    'com.android.application' .java :base apply plugin: 'com.android.library'
  2. Single-feature instant app .java :app .java .xml .png apply plugin:

    'com.android.application' .java :base !//apply plugin: 'com.android.library' apply plugin: 'com.android.feature'
  3. Single-feature instant app .java :app .java .xml .png apply plugin:

    'com.android.application' .java :base !//apply plugin: 'com.android.library' apply plugin: 'com.android.feature' :instantapp apply plugin: 'com.android.instantapp'
  4. Single-feature instant app :app apply plugin: 'com.android.application' :base baseFeature true

    dependencies { !//… application project(‘:app') } :instantapp apply plugin: 'com.android.instantapp'
  5. 4MB limit • You: <4MB? NO WAI • Me: YAS

    WAI # • APK Analyzer, Proguard, shrink resources/unused resources, .webp, … • Android Instant Apps: Best practices for managing download size • Wojtek Kaliciński: #SmallerAPK, session at Google I/O '17
  6. Deep links <activity android:name=".HelloActivity" android:label="@string/title_activity_hello"> <intent-filter> <action android:name="android.intent.action.VIEW" !/> <category

    android:name="android.intent.category.BROWSABLE" !/> <category android:name="android.intent.category.DEFAULT" !/> <data android:scheme="https" !/> <data android:scheme="http" !/> <data android:host="hello.instantappsample.com" !/> <data android:pathPrefix="/hello" !/> !</intent-filter> !</activity> !!!<!-- https:!//hello.instantappsample.com/hello/world !!-->
  7. Deep links !// Later in activity onCreate final Uri uri

    = getIntent().getData(); if (uri !!= null) { uri.getPathSegments(); !// List ["hello", "world"] }
  8. App Links <activity android:name=".HelloActivity" android:label="@string/title_activity_hello"> <intent-filter> <action android:name="android.intent.action.VIEW" !/> <category

    android:name="android.intent.category.BROWSABLE" !/> <category android:name="android.intent.category.DEFAULT" !/> <data android:scheme="https" !/> <data android:scheme="http" !/> <data android:host="hello.instantappsample.com" !/> <data android:pathPrefix="/hello" !/> !</intent-filter> !</activity>
  9. App Links <activity android:name=".HelloActivity" android:label="@string/title_activity_hello"> <intent-filter android:autoVerify="true"> <action android:name="android.intent.action.VIEW" !/>

    <category android:name="android.intent.category.BROWSABLE" !/> <category android:name="android.intent.category.DEFAULT" !/> <data android:scheme="https" !/> <data android:scheme="http" !/> <data android:host="hello.instantappsample.com" !/> <data android:pathPrefix="/hello" !/> !</intent-filter> !</activity>
  10. App Links • Upload a special JSON to a “well-known”

    location on your servers.
 https://<your.server>/.well-known/assetlinks.json • https://d.android.com/training/app-links/index.html • http://zdominguez.com/2017/01/20/testing-autoverify.html • App links assistant in Android Studio • MCE 2017: Cyril Mottier, Seamless Linking to Your App
  11. Default URL <activity android:name=".HelloActivity" android:label="@string/title_activity_hello"> <intent-filter> <action android:name="android.intent.action.MAIN" !/> <category

    android:name="android.intent.category.LAUNCHER" !/> !</intent-filter> <intent-filter> …q !</intent-filter> <meta-data android:name="default-url" android:value="https:!//hello.instantappsample.com/hello" !/> !</activity>
  12. What API levels does this support? Google I/O ’16 Keynote:

    “All the way back to Jelly Bean!!!1” Demoed on a KitKat device! Android 5.0 Lollipop (API 21)+
  13. Restrictions • Only available device identifier: Advertising ID • You

    can’t see a full list of apps installed on the device • Can’t change device settings such as change the user's wallpaper • No running in the background • No push notifications • No access to external storage • You’ll receive only some implicit broadcasts
  14. Restrictions • Network traffic from inside the instant app must

    be encrypted using a TLS protocol like HTTPS
  15. Tools • Android Studio 3.0, Android Gradle Plugin 3.0. •

    Instant Apps SDK (downloadable from the SDK Manager in AS). •aimplementation 'com.google.android.instantapps:instantapps:1.0.0' • Mostly all existing libraries, subject to “requirements & restrictions” • Mostly normal workflow: run from AS, attach debugger, etc.
 (Note: need to sign in with a Google account on device/emulator.)
  16. https://developer.android.com/topic/instant-apps/index.html “Native Android apps that run instantly,
 without the installation”

    “An upgrade to your existing Android app, not a new, separate app. It's the same Android APIs, the same project, and the same source code.”
  17. Learn more… • Docs at https://g.co/instantapps • Podcasts: • Fragmented

    #090 with Zarah Dominguez, • ADB 84: Instant Apps • 3 Google I/O '17 sessions (linked here, here and here) • Android Instant Apps, step-by-step: how Vimeo went about it • From Westinghouse to Android Instant apps, a BuzzFeed Journey • Ask me @marcinkozinski

More Decks by Marcin Koziński

Other Decks in Technology