问题描述
postInstallIntent在安装后会丢失捆绑包附加信息。我通过以下方式创建postInstallIntent:
val intent: Intent?
intent = Intent(Intent.ACTION_VIEW,Uri.parse("https://www.test.ru/activity/main/"))
intent.setPackage(context.packageName)
intent.addCategory(Intent.CATEGORY_broWSABLE)
intent?.putExtra(EXTRA_FirsT,data1)
intent?.putExtra(EXTRA_SECOND,data2)
比称呼它:
InstantApps.showInstallPrompt(
activity,intent,REQUEST_CODE,INSTALL_REFERRER
)
它会打开请求的活动,但是当我尝试从已安装的应用程序中的意图intent.extras
获取数据时,捆绑包为空。
我在做什么错或者是showInstallPrompt的问题?
解决方法
我了解到您希望将数据从Instant应用程序传递到已安装的应用程序,这可能通过以下方式发生,这是Android文档的支持:
- 对于Android 8.0(API级别26)及更高版本,您可以使用Cookie API sample app
- 对于Android 7.1(API级别25)及更低版本,您可以使用Storage API sample app
有关更多详细信息,请参见以下参考文献:
https://developer.android.com/topic/google-play-instant/getting-started/instant-enabled-app-bundle
How can I restore data from instant app to installed app?
How to transfer the shared prefs from Instant app to full app How to store data in android instant app and restore it in installed app
现在,就我而言,我正在使用正常功能通过以下功能打开应用的安装版本
private fun showInstallPrompt() {
val postInstall = Intent(Intent.ACTION_MAIN)
.addCategory(Intent.CATEGORY_DEFAULT)
.setPackage(packageName)
InstantApps.showInstallPrompt(this@MainActivity,postInstall,null)
}