小编sj.*_*.94的帖子

应用程序内更新(立即)不重新启动应用程序

面临即时应用程序更新模式的问题。成功完成应用程序更新后,一切都会关闭,并且不会重新启动应用程序。这就是问题所在。但android文档说:

全屏用户体验,要求用户更新并重新启动应用程序才能继续使用该应用程序。此用户体验最适合更新对于继续使用应用程序至关重要的情况。用户接受立即更新后,Google Play 会处理更新安装和应用重新启动。

implementation 'com.google.android.play:core:1.9.1'
implementation 'com.google.android.play:core-ktx:1.8.1'
Run Code Online (Sandbox Code Playgroud)

代码

class MainActivity : AppCompatActivity() {

    companion object {
        const val UPDATE_REQUEST_CODE = 112
        const val TAG = "MainActivity"
    }

    private var appUpdateManager: AppUpdateManager? = null

    override fun onCreate(savedInstanceState: Bundle?) {
        super.onCreate(savedInstanceState)
        setContentView(R.layout.activity_main)
        findViewById<TextView>(R.id.tv_text).text = "Version " + BuildConfig.VERSION_NAME

        // Returns an intent object that you use to check for an update.
        appUpdateManager = AppUpdateManagerFactory.create(this)
    }

    private val listener: InstallStateUpdatedListener =
        InstallStateUpdatedListener { installState ->
            if (installState.installStatus() == InstallStatus.DOWNLOADED) {
                // After …
Run Code Online (Sandbox Code Playgroud)

android in-app-update google-play-core

11
推荐指数
1
解决办法
1935
查看次数

标签 统计

android ×1

google-play-core ×1

in-app-update ×1