I am not able to see the Google In-App Updates working in my application. Here is the way I have implemented my code, but it appUpdateInfo always returns UPDATE_NOT_AVAILABLE (1).
onCreate Method
appUpdateManager = AppUpdateManagerFactory.create(this)
appUpdateManager.registerListener(this)
val appUpdateInfoTask = appUpdateManager.appUpdateInfo
appUpdateInfoTask.addOnSuccessListener {appUpdateInfo ->
try {
if(appUpdateInfoTask.isComplete){
if (appUpdateInfo.updateAvailability() == UPDATE_AVAILABLE) {
ToastUtils.showShort("Update Available" + appUpdateInfo.isUpdateTypeAllowed(FLEXIBLE))
if(appUpdateInfo.isUpdateTypeAllowed(FLEXIBLE)){
ToastUtils.showShort("Flexi Update")
requestAppUpdate(appUpdateManager.appUpdateInfo.getResult(), FLEXIBLE)
}else if(appUpdateInfo.isUpdateTypeAllowed(IMMEDIATE)){
ToastUtils.showShort("Immediate Update")
requestAppUpdate(appUpdateManager.appUpdateInfo.getResult(), IMMEDIATE)
}
}
}
} catch (e: Exception) {
Log.e("Update Exception", e.message)
}
}
onResume Method
override fun onResume() {
super.onResume()
val appUpdateInfoTask = appUpdateManager.appUpdateInfo
appUpdateInfoTask.addOnCompleteListener {
Log.e("Update Complete", "Complete")
}
appUpdateInfoTask.addOnSuccessListener {
if(appUpdateInfoTask.isComplete){
if (it.installStatus() == DOWNLOADED) {
showUpdateSnackbar()
}
}
}
}
onDestroy Method
override fun onDestroy() {
super.onDestroy()
appUpdateManager.unregisterListener(this)
}
onActivityResult Method
override fun onActivityResult(requestCode: Int, resultCode: Int, data: Intent?) {
super.onActivityResult(requestCode, resultCode, data)
if (requestCode == REQUEST_CODE_TO_FETCH_UPDATES) {
when (resultCode) {
Activity.RESULT_OK -> {
ToastUtils.showShort("Access to Update Granted")
}
Activity.RESULT_CANCELED -> {
ToastUtils.showShort("Access to Update Cancelled")
}
ActivityResult.RESULT_IN_APP_UPDATE_FAILED -> {
ToastUtils.showShort("Access to Update Failed")
}
}
}
}
Key Points
- Uploaded my app on the internal test track with Android App Bundle Format
- App Update is available on the store(on internal track) when my code written above in onCreate returns UPDATE_NOT_AVAILABLE.
- I have uploaded the using Google Play Developers API, and have set the inAppUpdatePriority as 5
QUERIES:
- I have tried updating the app many times on the store and I can never see an update on my app via this code.WHY?
- How can I see actual FLEXIBLE or IMMEDIATE Update by testing from the Internal test track? Where is the way to set that configuration?