【问题标题】:Problem with InstantApps.showInstallPrompt and postInstallIntent. Intent extras loseInstantApps.showInstallPrompt 和 postInstallIntent 存在问题。意图额外损失
【发布时间】:2021-01-11 14:02:28
【问题描述】:

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 的问题?

【问题讨论】:

    标签: android-instant-apps android-app-bundle


    【解决方案1】:

    我了解到您希望将数据从您的免安装应用传递到已安装的应用,这可能会在 Android 文档的支持下通过以下方式发生:

    1. 对于 Android 8.0(API 级别 26)及更高版本,您可以使用 Cookie API sample app
    2. 对于 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, 0, null)
        }
    

    【讨论】:

      猜你喜欢
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 2017-03-18
      • 2013-11-20
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      相关资源
      最近更新 更多