Warning: file_get_contents(/data/phpspider/zhask/data//catemap/3/android/188.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
Android 无法在应用程序更新对话框中显示播放商店_Android_Google Play - Fatal编程技术网

Android 无法在应用程序更新对话框中显示播放商店

Android 无法在应用程序更新对话框中显示播放商店,android,google-play,Android,Google Play,我正在通过Play Store API查看应用程序内更新。我遵循了文档和其他一些文章中的示例。但我仍然无法让它显示Play Store提供的更新对话框 我见过一些应用程序这样做,显示一个对话框提示用户开始更新,但使用FakeAppUpdateManager似乎无法做到这一点 我必须使用真正的版本来测试它吗?或者我需要为FakeAppUpdateManager进行一些配置吗 private fun checkForUpdates() { val appUpdateManager = if

我正在通过Play Store API查看应用程序内更新。我遵循了文档和其他一些文章中的示例。但我仍然无法让它显示Play Store提供的更新对话框

我见过一些应用程序这样做,显示一个对话框提示用户开始更新,但使用
FakeAppUpdateManager
似乎无法做到这一点

我必须使用真正的版本来测试它吗?或者我需要为
FakeAppUpdateManager
进行一些配置吗

private fun checkForUpdates() {
    val appUpdateManager = if (BuildConfig.DEBUG) {
        FakeAppUpdateManager(this).apply {
            setUpdateAvailable(UpdateAvailability.UPDATE_AVAILABLE)
            setUpdatePriority(5)
        }
    } else {
        AppUpdateManagerFactory.create(this)
    }

    // Returns an intent object that you use to check for an update.
    val appUpdateInfoTask = appUpdateManager.appUpdateInfo

    // Checks that the platform will allow the specified type of update.
    appUpdateInfoTask.addOnSuccessListener { appUpdateInfo ->
        if (
            appUpdateInfo.updateAvailability() == UpdateAvailability.UPDATE_AVAILABLE &&
            // For a flexible update, use AppUpdateType.FLEXIBLE
            appUpdateInfo.isUpdateTypeAllowed(AppUpdateType.IMMEDIATE)
        ) {
            // Create a listener to track request state updates.
            val listener = { state: InstallState ->
                // (Optional) Provide a download progress bar.
                if (state.installStatus() == InstallStatus.DOWNLOADING) {
                    val bytesDownloaded = state.bytesDownloaded()
                    val totalBytesToDownload = state.totalBytesToDownload()
                    // Show update progress bar.
                }
                // Log state or install the update.
            }

            // Before starting an update, register a listener for updates.
            appUpdateManager.registerListener(listener)

            // Request the update.
            appUpdateManager.startUpdateFlowForResult(
                // Pass the intent that is returned by 'getAppUpdateInfo()'.
                appUpdateInfo,
                // Or 'AppUpdateType.FLEXIBLE' for flexible updates.
                AppUpdateType.FLEXIBLE,
                // The current activity making the update request.
                this,
                // Include a request code to later monitor this update request.
                UPDATE_RC,
            )

            // When status updates are no longer needed, unregister the listener.
//                appUpdateManager.unregisterListener(listener)
        }
    }
}

您必须使用alpha、beta或public频道之一发布。内部应用程序共享是否有效?是的,可以