Skip to content

Instantly share code, notes, and snippets.

Last active August 10, 2019 19:22
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
Star You must be signed in to star a gist
What would you like to do?
Activity with AppUpdateWrapper
* Basic activity that runs flexible update
class FlexibleUpdateActivity : AppCompatActivity(), AppUpdateView {
* Update flow
private lateinit var updateWrapper: AppUpdateWrapper
override fun onCreate(savedInstanceState: Bundle?) {
// Creates flexible update flow that (if cancelled) will ask again tomorrow
updateWrapper = startFlexibleUpdate(
UpdateFlowBreaker.forOneDay(getSharedPreferences("uiState", Context.MODE_PRIVATE))
// Passes an activity result to wrapper to check for play-core interaction
override fun onActivityResult(requestCode: Int, resultCode: Int, data: Intent?) {
super.onActivityResult(requestCode, resultCode, data)
if (updateWrapper.checkActivityResult(requestCode, resultCode)) {
// Result handled and processed
// Process your request codes
/* AppUpdateView implementation */
// AppUpdateManager needs your activity to start dialogs
override val activity: Activity get() = this
// Update is downloaded and ready to install
override fun updateReady() {
// Display confirmation dialog of your choice and complete update...
// ...or cancel it
// Update check critical error (effective for IMMEDIATE flow)
override fun updateFailed(e: Throwable) {
Toast.makeText(this, "Update failed", Toast.LENGTH_SHORT).show()
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment