0

Any option to customize the Google play update the default prompt from the google-play-core library.

I need a customized popup.

I have followed this doc to achieve in-app update modal.

https://developer.android.com/guide/playcore/in-app-updates

sejn
  • 2,040
  • 6
  • 28
  • 82

1 Answers1

0

You should use a custom Dialog or fragment for it. and after clicking the update button you navigate direct to the playstore. like that

val appUpdateManager = AppUpdateManagerFactory.create(this)
    val appUpdateInfoTask = appUpdateManager.appUpdateInfo
    // Checks that the platform will allow the specified type of update.
    appUpdateInfoTask.addOnSuccessListener { appUpdateInfo ->
        Log.d(TAG, "checkForAppUpdate: checking update")
        if (appUpdateInfo.updateAvailability() == UpdateAvailability.UPDATE_AVAILABLE && appUpdateInfo.isUpdateTypeAllowed(
                AppUpdateType.FLEXIBLE
            )
        ) {
            updateDialog = Dialog(this, R.style.in_app_update_theme)
            updateDialog.requestWindowFeature(Window.FEATURE_NO_TITLE)
            updateDialog.setCancelable(false)
            updateDialog.setContentView(R.layout.in_app_update)

            val updateBtn = updateDialog.findViewById(R.id.updateBtn) as Button
            val laterBtn = updateDialog.findViewById(R.id.laterBtn) as Button
            updateBtn.setOnClickListener {
                try {
                    startActivity(
                        Intent(
                            Intent.ACTION_VIEW,
                            Uri.parse("https://play.google.com/store/apps/details?id=your package name")
                        )
                    )
                } catch (ex: Exception) {
                }
                updateDialog.dismiss()
            }
            laterBtn.setOnClickListener { updateDialog.dismiss() }
            updateDialog.show()

        }
    }