Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Is there an Android build flag to check for APK versus Instant App version of an App

Just like BuildConfig.FLAVOR and BuildConfig.DEBUG is there a build flag to check at runtime for the APK version or the Instant App version of an Android application ?

Or is there another way to get the information ?

like image 970
avianey Avatar asked Jun 01 '17 13:06

avianey


People also ask

What are examples of instant apps?

5 examples of Android instant apps you can trySkyscanner: flights and hotels: access to cheap tickets, accommodation and car rental, with an alert system. NYTimes Crossword: crosswords of The New York Times. Buzzfeed: Quiz, Tasty, News: full access to the platform app.

Where can I find APK files on Android?

If you want to locate the APK files in your Android phones, you can find the APK for user-installed apps under /data/app/directory while the preinstalled ones are located in /system/app folder and you can access them by using ES File Explorer.

What is the package manager for Android?

Package Manager is a highly powerful application to manage apps, both system and user, installed on an android device.

How do I distribute an APK for testing?

Distribute your app to testersSelect your Firebase project when prompted. On the Releases page, select the app you want to distribute from the drop-down menu. Drag your app's APK file to the console to upload it. When the upload completes, specify the tester groups and individual testers you want to receive the build.


2 Answers

Add to the module build.gradle the dependency : implementation 'com.google.android.instantapps:instantapps:1.0.0' then you will be able to use the function InstantApps.isInstantApp(this).

Please note that you must use Maven Google by changing your repositories in the project build.gradle :

buildscript {
    repositories {
        maven {
            url 'https://maven.google.com'
        }
        jcenter()
    }
    ...
}

allprojects {
    repositories {
        maven {
            url 'https://maven.google.com'
        }
        jcenter()
    }
}

Android Instant Apps API reference

like image 143
Guillaume Avatar answered Oct 13 '22 01:10

Guillaume


Easiest way is to use PackageManager.isInstantApp() :

https://developers.google.com/android/reference/com/google/android/gms/instantapps/PackageManagerCompat.html#isInstantApp()

Or, a regular (non-appcompat version) https://developer.android.com/reference/android/content/pm/PackageManager#isInstantApp()

Also has an override which accepts package name as a string, which allows to check other apps, if permissions allow.

like image 38
Over17 Avatar answered Oct 13 '22 02:10

Over17