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

Building Instant Apps for the future

Building Instant Apps for the future

Avatar for Aravind Raj

Aravind Raj

October 13, 2017

Other Decks in Technology

Transcript

  1. Instant App • Android Instant App lets user to run

    the app without installation. • You can run an app instantly just like an website by clicking on the link. • When the user clicks on a particular link, through URL the requested feature alone gets identified & downloaded instead of requesting the user to download the whole app from the Play store or opening the website. • It comes with high performance, and user experience just like your native app.
  2. Let’s build. Designr is an App for Designers and Artist

    to share there artwork to the community. Let us take this scenario and see how to make this an Instant App.
  3. Configuring your existing project These are the commonly used structure

    for Android Native app. Our first task is to split the project feature wise.
  4. URL Linking Every activity is associated with an URL path.

    HTTP is not supported Instant Apps should use only HTTPS. One Activity calls another activity through URL (Deep linking) only. <manifest xmlns:android="http://schemas.android.com/apk/res/android" package="com.aravindcraj.designr.home"> <application> <activity android:name=".HomeActivity"> <intent-filter android:order=“1"> . . . <data android:host="designrapp.com" android:pathPattern="/.*" android:scheme="https" /> </intent-filter> . . . </activity> </application> </manifest>
  5. App links Every activity is associated with an URL path.

    Make the Instant App discoverable via URL using Firebase Dynamic links. Authorise the URL, So it becomes discoverable and handle all the URL paths in the Instant App. <manifest xmlns:android="http://schemas.android.com/apk/res/android" package="com.aravindcraj.designr.home"> <application> <activity android:name=".HomeActivity"> <intent-filter android:order="1"> <action android:name="android.intent.action.VIEW" /> <category android:name="android.intent.category.BROWSABLE" /> <category android:name="android.intent.category.DEFAULT" /> <data android:host="designrapp.com" android:pathPattern="/.*" android:scheme="https" /> </intent-filter> <intent-filter> <action android:name="android.intent.action.MAIN" /> <category android:name="android.intent.category.LAUNCHER" /> </intent-filter> </activity> </application> </manifest>
  6. Modularising the App Understand the features of your app and

    modularise them. And also keep the features separately which you want to be supported for Instant App.
  7. Smart Lock for Sign up So when the user sign

    up for the first time store the credentials with Google Credentials API. Auth.CredentialsApi.save(mCredentialsClient, credential).setResultCallback( new CarrierMessagingService.ResultCallback() { @Override public void onResult(Status status) { if (status.isSuccess()) { // Credentials were saved } else { if (status.hasResolution()) { // Try to resolve the save request. This will prompt the user if // the credential is new. try { status.startResolutionForResult(this, RC_SAVE); } catch (IntentSender.SendIntentException e) { // Could not resolve the request } } } } }); All these details can be accessed anytime using request();
  8. Smart Lock for Sign in So the next time when

    user opens the app we request for the stored credentials through Credentials API. Auth.CredentialsApi.request(mCredentialsClient, mCredentialRequest).setResultCallback( new CarrierMessagingService.ResultCallback() { @Override public void onResult (CredentialRequestResult credentialRequestResult){ if (credentialRequestResult.getStatus().isSuccess()) { // Handle successful credential requests } else { // Handle unsuccessful and incomplete credential requests } } }); We either login using credentials directly or fill the credentials for the user.
  9. Activities & Fragments Every activity is associated with an URL

    path. One Activity calls another activity through URL only. Fragments are not associated with URL directly. They’re associated with parent activity from where we can navigate to the fragment.
  10. Runtime permissions We can request permissions to the user whenever

    needed using Runtime permission API. if(ContextCompat.checkSelfPermission(thisActivity, Manifest.permission.READ_CONTACTS) !=PackageManager.PERMISSION_GRANTED) { ActivityCompat.requestPermissions(thisActivity, new String[]{Manifest.permission.READ_CONTACTS}, MY_PERMISSIONS_REQUEST_READ_CONTACTS); }
  11. Network calls & Local storage Just like the native Android

    app Instant App also supports Network call, on device storage etc. Since Instant App each feature module size should not exceed 4MB (i.e. Base module + feature) using 3rd party library can be avoided. All Local storage such as DB, Shared Preference etc. can be accessed even after the Instant App is killed until the device is severely constrained. All network traffic inside the Instant App should use only HTTPS.
  12. Services and Background Notifications Instant Apps cannot use Background services

    and Background Notifications. Foreground services are available.
  13. Limitations of Instant App Push notifications are not currently supported

    on Instant Apps. Cannot create an Activity that is not associated with any UI. Instant Apps can only be started through URL not by another Activity. Cannot change devices settings such as Wallpaper, Ringtone, Profiles etc.