是否有 Android 构建标志来检查 APK 与应用程序的即时应用程序版本
Is there an Android build flag to check for APK versus Instant App version of an App
就像 BuildConfig.FLAVOR
和 BuildConfig.DEBUG
是否有一个构建标志可以在运行时检查 Android 应用程序的 APK 版本或 Instant App 版本?
或者有其他获取信息的方法吗?
添加到模块 build.gradle
依赖项:implementation 'com.google.android.instantapps:instantapps:1.0.0'
然后你就可以使用函数 InstantApps.isInstantApp(this)
.
请注意,您必须通过更改项目中的存储库来使用 Maven Google build.gradle
:
buildscript {
repositories {
maven {
url 'https://maven.google.com'
}
jcenter()
}
...
}
allprojects {
repositories {
maven {
url 'https://maven.google.com'
}
jcenter()
}
}
是的,你可以判断当前应用是Installed App还是Instant app.First所有在你的feature module中添加依赖build.gradle
api "com.google.android.instantapps:instantapps:1.0.0"
将您的项目级别 build.gradle 与此匹配
buildscript {
repositories {
maven { url 'https://maven.google.com' }
jcenter()
}...
}
allprojects {
repositories {
maven { url 'https://maven.google.com' }
jcenter()
}
}
最后在运行时你可以写
if (InstantApps.isInstantApp(this)) {
// Do something like, show install button
} else {
// Do something like, hide install button
}
最简单的方法是使用 PackageManager.isInstantApp()
:
或者,常规(非应用程序兼容版本)https://developer.android.com/reference/android/content/pm/PackageManager#isInstantApp()
还有一个覆盖接受包名称作为字符串,如果权限允许,它允许检查其他应用程序。
就像 BuildConfig.FLAVOR
和 BuildConfig.DEBUG
是否有一个构建标志可以在运行时检查 Android 应用程序的 APK 版本或 Instant App 版本?
或者有其他获取信息的方法吗?
添加到模块 build.gradle
依赖项:implementation 'com.google.android.instantapps:instantapps:1.0.0'
然后你就可以使用函数 InstantApps.isInstantApp(this)
.
请注意,您必须通过更改项目中的存储库来使用 Maven Google build.gradle
:
buildscript {
repositories {
maven {
url 'https://maven.google.com'
}
jcenter()
}
...
}
allprojects {
repositories {
maven {
url 'https://maven.google.com'
}
jcenter()
}
}
是的,你可以判断当前应用是Installed App还是Instant app.First所有在你的feature module中添加依赖build.gradle
api "com.google.android.instantapps:instantapps:1.0.0"
将您的项目级别 build.gradle 与此匹配
buildscript {
repositories {
maven { url 'https://maven.google.com' }
jcenter()
}...
}
allprojects {
repositories {
maven { url 'https://maven.google.com' }
jcenter()
}
}
最后在运行时你可以写
if (InstantApps.isInstantApp(this)) {
// Do something like, show install button
} else {
// Do something like, hide install button
}
最简单的方法是使用 PackageManager.isInstantApp()
:
或者,常规(非应用程序兼容版本)https://developer.android.com/reference/android/content/pm/PackageManager#isInstantApp()
还有一个覆盖接受包名称作为字符串,如果权限允许,它允许检查其他应用程序。