Warning: file_get_contents(/data/phpspider/zhask/data//catemap/0/asp.net-mvc/17.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_In App Update - Fatal编程技术网

Android 如何实现应用内即时更新?

Android 如何实现应用内即时更新?,android,in-app-update,Android,In App Update,我正在尝试在我的应用程序中使用应用程序内即时更新,并使用内部测试跟踪对其进行验证。 我从这里开始阅读文档 但是仍然无法看到更新对话框。我收集了日志,如下所示: AppUpdateService:requestUpdateInfo(com.xxx.xxx) AppUpdateService:启动与服务的绑定。 AppUpdateService:ServiceConnectionImpl.onServiceConnected(组件信息{com.android.vending/com.google.a

我正在尝试在我的应用程序中使用应用程序内即时更新,并使用内部测试跟踪对其进行验证。 我从这里开始阅读文档 但是仍然无法看到更新对话框。我收集了日志,如下所示:

AppUpdateService:requestUpdateInfo(com.xxx.xxx) AppUpdateService:启动与服务的绑定。 AppUpdateService:ServiceConnectionImpl.onServiceConnected(组件信息{com.android.vending/com.google.android.finsky.installservice.DevTriggeredUpdateService}) AppUpdateService:linkToDeath

代码如下:

private fun checkForUpdate():Boolean{
        val appUpdateManager = AppUpdateManagerFactory.create(context)

// Returns an intent object that you use to check for an update.
        val appUpdateInfoTask = appUpdateManager.appUpdateInfo
        var isUpdate = false;
        Log.d("MainActivity","init isUpdate=.."+isUpdate)
// 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)
            ) {
                Log.d("MainActivity","Update avlbl..")
                appUpdateManager.startUpdateFlowForResult(
                    // Pass the intent that is returned by 'getAppUpdateInfo()'.
                    appUpdateInfo,
                    // Or 'AppUpdateType.FLEXIBLE' for flexible updates.
                    AppUpdateType.IMMEDIATE,
                    // The current activity making the update request.
                    context as Activity,
                    // Include a request code to later monitor this update request.
                    MY_REQUEST_CODE)
                isUpdate=true
                Log.d("MainActivity","request Update avlbl.."+isUpdate)

            }
        }
        return isUpdate
    }

    override fun onResume() {
        super.onResume()
        val updateManager = AppUpdateManagerFactory.create(this)
        updateManager.appUpdateInfo
            .addOnSuccessListener {
                if (it.updateAvailability() ==
                    UpdateAvailability.DEVELOPER_TRIGGERED_UPDATE_IN_PROGRESS) {
                    updateManager.startUpdateFlowForResult(
                        it,
                        AppUpdateType.IMMEDIATE,
                        context as Activity,
                        MY_REQUEST_CODE)
                    Log.d("MainActivity","oDEVELOPER_TRIGGERED_UPDATE_IN_PROGRESS")
                }
                Log.d("MainActivity","o==DEVELOPER_TRIGGERED_UPDATE_IN_PROGRESS")
            }
    }