A Step-by-Step Guide to Building ‘Instant’ Apps

Everyone has randomly downloaded several apps and not deleted them for months, years, or eternity!
I bet You have some of those apps now!

People can now use an app or game without installing it first. Increase engagement with your Android app and gain more installs by surfacing your instant app across the Play Store and Google Play Games app.

Yes, you heard it right, Google play instant now provides us with these features and Android’s new app publishing format, the Android App Bundle, makes it easier than ever to offer a Google Play Instant experience. 

Let’s see how to build one –

Followings Points need to be considered before building one –

– Supported permissions and operations

Instant-enabled app bundles can only use permissions from the following list:

Handling common unsupported permissions

The following is a list of common, non-supported permissions you must remove from your application and the recommended migration path for each:

  • ACCESS_WIFI_STATE
  • BILLING: This is a deprecated permission. Use the Google Play Billing Library, which no longer requires the com.android.vending.BILLING permission.
  • READ/WRITE_EXTERNAL_STORAGE: Instant apps do not have access to external storage; use internal storage instead.
  • background services.
  • Send notifications when running in the background.

Access to Installed apps

Apps with below flags.

Lets Build . . .

Dependendcies
implementation("com.google.android.gms:play-services-instantapps:17.0.0")
Update the target sandbox version

Your instant app’s AndroidManifest.xml file needs to be updated to target the sandbox environment that Google Play Instant supports.

<manifest
   xmlns:android="http://schemas.android.com/apk/res/android"
  ...
   android:targetSandboxVersion="2" ...>
Declare instant-enabled app modules
  1. Open the Project panel by selecting View > Tool Windows > Project from the menu bar.
  2. Right-click on your base module, typically named ‘app’, and select Refactor > Enable Instant Apps Support.
  3. In the dialog that appears, select your base module from the dropdown menu.
  4. Click OK.

Android Studio adds the following declaration to the module’s manifest:

<manifest ... xmlns:dist="http://schemas.android.com/apk/distribution">
    <dist:module dist:instant="true" />
    ...
</manifest>
Display an install prompt

You may provide an instant experience for your user. once he likes next what within the instance experience you can ask user to install actual app using below code.

class MyInstantExperienceActivity : AppCompatActivity {
    // ...
    private fun showInstallPrompt() {
        val postInstall = Intent(Intent.ACTION_MAIN)
                .addCategory(Intent.CATEGORY_DEFAULT)
                .setPackage(your-installed-experience-package-name)

        // The request code is passed to startActivityForResult().
        InstantApps.showInstallPrompt(this@MyInstantExperienceActivity,
                postInstall, request-code, /* referrer= */ null)
    }
}
Lets Upload . . . .


Build > Build Bundle(s) / APK(s) > Build Bundle(s).

  • Requires Signing process
  • Valid keystores.
  • Version code must be less than uploaded version if app already present
Play store Process
Once this is Enabled, let’s upload our build to internal track
Once Build is uploaded, you should be able to see “Try Now” button and should be able to Try!
Image By StickMan

I would like to conclude, Every App provider must provide an initial look and feel for app, For better User understanding.

Summary

Instant Apps are the future. The ability to quickly use an app without installing it on your device is a feature too good to fizz out. With the steps mentioned in this article, you should be able to seamlessly offer this nifty feature to your users and greatly enhance your value-offering.

Leave a Reply

Fill in your details below or click an icon to log in:

WordPress.com Logo

You are commenting using your WordPress.com account. Log Out /  Change )

Facebook photo

You are commenting using your Facebook account. Log Out /  Change )

Connecting to %s

This site uses Akismet to reduce spam. Learn how your comment data is processed.