Native Android apps, without the installation.
1. What is Android Instant Apps?
As a Developer ever thought to bring users into your apps more quickly and easily.
Android Instant Apps allows Android users to run your apps instantly, without installation. Android users experience what they love about apps — fast and beautiful user interfaces, high performance, and great capabilities — with just a tap.
2. Why you need to make Android Instant Apps?
You can let user try few feature of your native app without installing and they can download installable version when they want.So this brings more customers to your app.
3. How to make Android Instant Apps?
Note:Android Instant Apps only work on Android devices running on Android 6.0 (API level 23) or higher
Android Instant Apps enables native Android applications to run in response to launching a URL, without installing the app. Instant apps can use many Android APIs and you use Android Studio to build them.
Development environment for Android Instant Apps
- JDK 1.8
- Android Studio version 3.0 or later
- Android SDK 6.0+
- Android SDK Build Tools 26.x or later
- Android SDK Tools 25.x or later
- Android SDK Platform Tools 25.x or later
Instant Apps Development SDK.
- Open the Android SDK Manager by clicking Tools > Android > SDK Manager.
- Click the SDK Tools tab.
- From the list, select Instant Apps Development SDK.
- Click Apply.
- Click Finish.
opt-in to Android Instant apps in the Settings app of your device by going to Google > Instant Apps. Note that if you do not opt-in, developer mode does not work on the device. The first time you navigate to a instant app, the system automatically asks you to opt-in.
With Android Instant Apps, users can use a single feature of an app without having to install the app with all its other features. Each feature within the instant app should have at least one Activity that acts as the entry-point for that feature. you need to break up your app into smaller modules and refactor them into feature modules.
Every instant app must have one (and only one) base feature APK. You can have feature APKs in addition to your base feature APK ,If your Instant app has more features.
When users request a feature from an instant app, they get two feature APKs: the corresponding feature APK and the base feature APK. If the same user requests another feature from the same instant app, they might receive just the feature APK because they have already downloaded the base feature APK. Of course, if the instant app only has one feature — and thus only a base feature APK — users only receive the base feature APK.
To download a feature of an instant app from Google Play, users need only to click a link. After Google Play finds an instant app that matches the link requested by the user, Google Play sends the corresponding feature APKs for that feature to the user’s device and the Android system then launches the feature. If Google Play cannot find a match, it alerts the Android system. The system then broadcasts an intent to the system to handle the URL.
For this reason, each entry-point activity in an instant app needs to be addressable: it needs to correspond to a unique URL address. To provide a unique URL address for each feature, the instant app specifies a different path underneath the domain for each feature.
Suppose your app show news by particular city in this case your URL matches
The URL address for the CityNews activity is similar to the AllNews activity except that the CityNews activity has a city appended to the URL.
The manifest for the feature needs to specify both a path for each activity and a priority order for the activities, in case of multiple matches.
If Google Play received a request for the URL ‘http://example.com/news/abab', it matches both the AllNews and the CityNews activity. Google Play needs to pick one of the two activities as the starting point for the feature. Because the instant app specifies that the CityNews activity has a higher priority than the AllNews activity, Google Play specifies to the system to start the feature from the CityNews activity
So your manifest will be like
<action android:name="android.intent.action.VIEW" />
<category android:name="android.intent.category.BROWSABLE" />
<category android:name="android.intent.category.DEFAULT" />
<action android:name="android.intent.action.MAIN" />
<category android:name="android.intent.category.LAUNCHER" />
Here, “android:order” is priority.
For creating Instant app in Android studio,
- Start a new project
2. In the Minimum SDK list, select API 23: Android 6.0 (Marshmallow).
3. Under the Minimum SDK list, check Include Android Instant app support.
4. Select an Activity.
5. In the Configure Activity window, do the following:
- In the Instant App URL Host box, enter ‘myfirstinstantapp.example.com’.
- In the Instant App URL route box, enter ‘/hello’.
6.Finish and Run.
For more details about creating feature module you can see Google codelabs.
Note: When you run your app locally on a device or emulator, the Android system displays the default placeholder icon for your app. Once you have deployed your Instant App APK to the Google Play Console, the appropriate icon shows up when the instant app launches.
Android Instant Apps uses the runtime permission model introduced in Android 6.0 (API level 23).Instant apps can use the Android permissions shown in the list that follows. Any permission not shown in the list is not available to instant apps.
- INSTANT_APP_FOREGROUND_SERVICE only in Android O.
- READ_PHONE_NUMBERS only in Android O.
Note 1: All network traffic from inside the instant app must use HTTPS. Instant Apps does not support HTTP.
Note 2: The sum of the base feature and the feature APK must be under 4MB.
Note 3: Since App Links are regular URLs, apps can force them to be opened inside an in-app browser. Consider using Firebase Dynamic Links to wrap your URLs and guarantee that clicks on your links always take users to your instant app.
You can follow sample code provided by google
- Hello World sample app
This sample app demonstrates how to build an installed app and an instant app with the same behaviors. Get it on GitHub
- Hello multi feature module sample app
This sample app builds upon the Hello World sample app by moving its code into two feature modules. These modules can be run independently. Get it on GitHub
- Multi feature module sample app
This sample app demonstrates how to build an installed app and an instant app with the same behaviors. The functionality of the instant app is split in two features that you can launch individually on a device. Get it on GitHub
- Build flavors sample app
This sample app demonstrates how to build an installed app and an instant app with the same behaviors. The functionality of the instant app is split in two features that you can launch individually on a device.This sample also uses the concept of build flavors, providing both a “paid” and “free” version of the app. Get it on GitHub
- Google Analytics for Firebase sample app
This sample app demonstrates how to build an installed app and an instant app with the same behaviors. The app integrates Google Analytics for Firebase event logging into both the installed and instant app, demonstrating how to differentiate events raised in the two versions of the app. Get it on GitHub
If you liked my story please click on clap icon and if you want to read future stories by me related to Android Development please follow me.