Code Monkey home page Code Monkey logo

amazon-ivs-on-demand-android-demo's Introduction

Amazon IVS On-demand SDK delivery Android demo

This code sample shows how you can leverage Play Feature Delivery to enable on-demand delivery of the Amazon IVS Player SDK, which will be downloaded from the Google Play Store when requested.

A modularized app will create clearly defined boundaries between separate parts of your application, and allowing you to decrease your app’s size further. In practice, this means that you can call an API to install the module (the Amazon IVS Player SDK) after the app has been downloaded and installed on your user’s device. Using on-demand installation saves initial download time and size.

This is achieved by releasing your Android application with .aar bundles. (Note: this cannot be done with an .apk)

Setup Instructions

The setup is tailored for a project that uses the nav-graph navigation. Follow along for instructions. If needed, please refer to the Quick Start Guide provided by Google.

Step 1: Add a new Dynamic Module to your project

Click on File -> New -> New Module...

Select Dynamic Feature and enter all the values necessary.

Pick the desired feature type - in our case we use on-demand delivery.

Step 2: Create or update you Application class

The class must extend SplitCompatApplication - don't forget to add it as name in your application tag in theAndroidManifest.xml file. Override the attachBaseContext(..) function of the application and call SplitCompat.install(this).

Step 3: Install the split module in every activity that needs access to the feature module

If you wish to use the feature module after it's downloaded you must call SplitCompat.installActivity(this) in every activity that needs access to it. If you plan to use the module in an fragment, you must install it in the parent activity of the fragment.

Step 4: Add the play core and navigation feature-delivery dependency

Add the following:

api "androidx.navigation:navigation-dynamic-features-fragment:2.3.5"
implementation "com.google.android.play:core:1.10.0"

to your main gradle file to enable feature module loading when using the navigate(..) function to switch between fragments.

Step 5: Update your navigation host to use DynamicNavHostFragment

In your activity layout file change the navigation host name to:

android:name="androidx.navigation.dynamicfeatures.fragment.DynamicNavHostFragment"

Step 6: Listen for the feature download or add a custom AbstractProgressFragment

There are two ways to handle the feature download, either use the InstallManager to observe the feature download or create a fragment that extends the AbstractProgressFragment and implement the 3 callbacks to listener for the download state.

Both appoaches have known issues:

  • The manual install way described here has a bug with the installMonitor.isInstallRequired boolean. It will always return true even if you have the feature installed. This means that when you use the navigate(id, null, null, DynamicExtras(installMonitor) as described there and then use it again when the installation is completed - you'll have your fragment opened twice.
  • The custom progress fragment has a bug with the onProgress callback - it doesn't return values smoothly, so it'll jump from 1%-2% to 100%.

The demo app in this repository uses the custom progress fragment. The fragment is launched automatically when navigating to a fragment that is inside a feature module. To enable the progress fragment - set it as value in your nav_graph like so:

app:progressDestination="@id/loading_fragment"

When using the custom progress fragment you don't have to worry about download / install states as it will be handled automatically. If the fragment is loaded or already pre-loaded, it will be opened.

Step 7: Test your app

To test how the feature delivery works either upload your app to the Google Play Store, or use the bundletool to simulate the experience.


End result

amazon-ivs-on-demand-android-demo.mp4

Amazon IVS Documentation

License

This sample code is made available under a modified MIT license. See the LICENSE file.

amazon-ivs-on-demand-android-demo's People

Contributors

amazon-auto avatar egorbunovs avatar mboulin avatar slee-aws avatar wongvws avatar wongws avatar

Stargazers

 avatar  avatar

Watchers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.